Viewing Add dynamic date and time to webpage in EverWeb in this format mm/dd - hh:mm

Add dynamic date and time to webpage in EverWeb in this format mm/dd - hh:mm



User: Steve M. 12 years ago
Add dynamic date and time to webpage in EverWeb in this format mm/dd - hh:mm

I cannot seem to find any javascript/HTML snippet which will allow me to customize this exact format in 12hr (not 24hr) using white (ffffff) helvetica bold 9.35pt font.

I'm using it for a mock ipad newsletter which will load different stories upon page refresh.

Example: 9/5 - 3:15

Thanks in advance.
User: Jumbo T. 12 years ago
If you cannot find a prefab snippet, create your own :

http://trotter.is-best.net/includes/date.html
User: Jumbo T. 12 years ago
If you cannot find a prefab snippet, create your own :

http://trotter.is-best.net/includes/date.html
User: Steve M. 12 years ago
[quote name=Jumbo T. time=20/04/2014 1:32:41]If you cannot find a prefab snippet, create your own :

http://trotter.is-best.net/includes/date.html

Thank you for all of your help. The date was coming up 3/20 instead of the correct date of 4/20 so I added +1 after the d.getMonth(); line, that's the only part of the code I couldn't figure out how to change to what I wanted (and I'm not sure what that's going to do in December, but I'll cross that bridge when I come to it), plus there's a zero at the beginning of the hour, which I'll experiment with once the time changes to ten, eleven or twelve o'clock. I really appreciate all of the fixes you've come up with for me. Thanks again.
User: Jumbo T. 12 years ago
I overlooked that getmonth(0) is 0-11

getMonth() - Returns a zero-based integer (0-11) representing the month of the year.

So I updated the script :

theMonth = d.getMonth() + 1;

BTW. Since you wanted the hours 0-12, it will look odd when it's a quarter past 3 in the afternoon. You may want to add am and pm.

Last edit 12 years ago


Post Reply
You must login or signup to post.