forked from mrlaboratory/the-best-blogger-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdateTime.js
42 lines (41 loc) · 1.12 KB
/
dateTime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var timeFmt = 12;
var ampm ="";
var ttime = $('.todayDiv .time');
var ddate = $('.todayDiv .date');
setInterval(() => {
let day = new Date();
let hourr = day.getHours();
let minutess = day.getMinutes();
let secondss = day.getSeconds();
if(timeFmt==12){
if(hourr>12){
var hour = hourr-12;
if(hourr==12){
ampm ='AM';
}else{
ampm='PM';
}
}else{
hour = hourr;
if(hourr==12){
ampm ='PM';
}else{
ampm='AM';
}
}
}else{
hour = hourr;
}
var time = hour+":"+minutess+":"+secondss+" "+ampm;
ttime.text(time);
;})
const d = new Date();
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
const mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);
ddate.text(`${da}-${mo}-${ye}`);
if(dissableCopyText==true){
if (typeof document.onselectstart!="undefined" ) { document.onselectstart=new Function ("return false" );
} else { document.onmousedown=new Function ("return false" ); document.onmouseup=new Function ("return true" );
}
}