What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » JavaScript Localtime

JavaScript Localtime
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: JavaScript Localtime
I think this is what you are after, I wrote it myself so it might be able to be made smaller (using functions that I don't know about) but it will do.  Just put it in wherever you are wanting the time to be displayed.

code:
<script language="javascript" type="text/javascript" >var d=new Date();var days=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");document.write(days[d.getDay()]+" "+months[d.getMonth()]+" "+d.getDate()+", "+(d.getYear()+1900)+", "+(d.getHours()%12==0?"12":d.getHours()%12)+":"+(d.getMinutes()>9?d.getMinutes():"0"+d.getMinutes())+(d.getHours()<12?"am":"pm"));</script>


EDIT: should have refreshed the page I guess... and mine is only static, not a dynamic one like that either (it will only show the one time and not continually update... I guess you wanted that though)

EDIT2: fixed my code to have a prefixing 0 on the minutes when they are less than 10 :tongue:

EDIT3: Had a problem with the year that is now fixed.... why do they start at 1900?

This post was edited on 04-12-2007 at 04:15 AM by markee.
[Image: markee.png]
04-11-2007 02:59 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
JavaScript Localtime - by Eddie on 04-11-2007 at 01:42 PM
RE: PHP Localtime - by Ezra on 04-11-2007 at 01:49 PM
RE: PHP Localtime - by Eddie on 04-11-2007 at 01:51 PM
RE: PHP Localtime - by absorbation on 04-11-2007 at 01:55 PM
RE: PHP Localtime - by markee on 04-11-2007 at 02:07 PM
RE: PHP Localtime - by Eddie on 04-11-2007 at 02:23 PM
RE: PHP Localtime - by Ezra on 04-11-2007 at 02:24 PM
RE: JavaScript Localtime - by Eddie on 04-11-2007 at 02:25 PM
RE: JavaScript Localtime - by Ezra on 04-11-2007 at 02:36 PM
RE: JavaScript Localtime - by Eddie on 04-11-2007 at 02:39 PM
RE: JavaScript Localtime - by Ezra on 04-11-2007 at 02:48 PM
RE: JavaScript Localtime - by Eddie on 04-11-2007 at 02:50 PM
RE: JavaScript Localtime - by markee on 04-11-2007 at 02:59 PM
RE: JavaScript Localtime - by Eddie on 04-11-2007 at 03:33 PM
RE: JavaScript Localtime - by Matti on 04-14-2007 at 02:05 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On