10 examples of 'javascript get current time in 24 hour format' in JavaScript

Every line of 'javascript get current time in 24 hour format' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
26function getCurrentTime() {
27 //return the current time in format TTS can use
28 var d = new Date();
29 var returnString = new String();
30 returnString = " It is now, ";
31 returnString += d.getHours() + " " + d.getMinutes();
32 returnString += ". ";
33 return returnString;
34}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

101function getCurrentHour (gmt, currentDate) {
102 return (gmt ? currentDate.getUTCHours() : currentDate.getHours());
103}
41function get_time() {
42 return Date.now() + t_offset;
43}
3function getTime() {
4 const now = new Date();
5 const hours = now.getHours();
6 const minutes = now.getMinutes();
7 const time = `${hours < 10 ? `0${hours}` : hours}:${
8 minutes < 10 ? `0${minutes}` : minutes
9 }`;
10 clock.innerHTML = time;
11 return;
12}
23getCurrentTime() {
24 const time = new Date();
25 return `${this.checkDateFormat(time.getHours())}:${this.checkDateFormat(time.getMinutes())}:${this.checkDateFormat(time.getSeconds())}`;
26}
225function getTimeString() {
226 var date = new Date();
227 var hour = date.getHours();
228 var minute = date.getMinutes();
229
230 if (0 === minute) {
231 return convertNumToTok(hour) + ' dian whole';
232 } else {
233 return convertNumToTok(hour) + ' dian ' + convertNumToTok(minute) + ' fen';
234 }
235}
152function get_time()
153{
154 initPlayer();
155 return vlcCoreObj.get_time();
156}
26function getNow() {
27 var now = new Date();
28
29 return {
30 hours: now.getHours() + now.getMinutes() / 60,
31 minutes: now.getMinutes() * 12 / 60 + now.getSeconds() * 12 / 3600,
32 seconds: now.getSeconds() * 12 / 60
33 };
34}
26function timeTick(){
27 var time;
28 if(second<60){
29 time=second+"秒";
30 }
31 else if(second>=60 && second<3600){
32 time=(parseInt)(second/60)+"分"+second%60+"秒";
33 }else if(second>=3600){
34 time=(parseInt)(second/3600)+"时"+(parseInt)((second%3600)/60)+"分"+(second%3600)%60+"秒";
35 }
36 content="网页监听助手已运行"+time+",共刷新"+timerCount+"次,每"+timeInterval+"秒刷新一次。"+extInfo;
37
38
39 if(second%timeInterval==0)
40 {
41 var hour=(new Date()).getHours();
42 if(hour<stopHour||hour>=startHour)
43 {
44 $.get(location.href,function(data){
45 data=data.replace(/<!--[\s\S]+?-->/g,'');
46
47 if(source==''){
48 source=data;
49 }else if(source.localeCompare(data)!=0){
50 chrome.extension.sendMessage({message:'PageChangedEvent',url:location.href});
51 stopTimer();
52 location.reload();
53 }
54 timerCount++;
55 });
56 extInfo='';
57 }else{
58 extInfo="目前正处于休息时间,将于"+startHour+"点重新开始工作。";
59 }
60 }
61 second++;
62 $('#ymlInfo').html(content);
63}
44function getHours(time) {
45 return Math.floor(time);
46}

Related snippets