I have a simple snippet which prints full day, month, day of month, hour and minute.
Here is the code: http://jsfiddle.net/raNms/
I want to change where
Monday > Mon
Tuesday > Tue
...
and months:
January > Jan
February > Feb
...
Can it be done before appending to body? I don't want to replace the appended text but to print it correctly from the beginning.
The JavaScript:
var now= new Date(),
ampm= 'am',
h= now.getHours(),
m= now.getMinutes(),
s= now.getSeconds();
if(h>= 12){
if(h>12)h-= 12;
ampm= 'pm';
}
if(h<10) h= '0'+h;
if(m<10) m= '0'+m;
var time = now.toLocaleDateString()+' '+h+':'+m+' '+ampm
$('body').html(time);
Just add this:
var txt = now.toLocaleDateString().replace(/\b[a-z]+\b/gi,function($0){return $0.substring(0,3)});
Code: http://jsfiddle.net/raNms/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With