JavaScript Localtime - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: JavaScript Localtime (/showthread.php?tid=73515) JavaScript Localtime by Eddie on 04-11-2007 at 01:42 PM
ok i did a google search, and found something but it didnt work, and you all seem to be php whizzes so... RE: PHP Localtime by Ezra on 04-11-2007 at 01:49 PM
You don't know the users local time unless they tell you and you store it in a database. RE: PHP Localtime by Eddie on 04-11-2007 at 01:51 PM
quote:A PHP Script i found did it via javascript / php it just failed http://www.mtdev.com/2002/07/display-local-time/ RE: PHP Localtime by absorbation on 04-11-2007 at 01:55 PM
You can't figure it out. PHP's time function is got from the server, not a browser, therefore the time(); function matches what the server's time is. RE: PHP Localtime by markee on 04-11-2007 at 02:07 PM The reason why PHP cannot do this is because it is a server-side script, meaning it is all done from the server. Javascript is a client side script and that is why it is very easy to do using javascript. If you want some help, just give us the exact details of what you are after and we will head you in the right direction RE: PHP Localtime by Eddie on 04-11-2007 at 02:23 PM
quote:k... Example of wot i want: Wednesday April 11, 2007, 10:22pm thats how i want it layed out RE: PHP Localtime by Ezra on 04-11-2007 at 02:24 PM
But what do you want to show? RE: JavaScript Localtime by Eddie on 04-11-2007 at 02:25 PM Just a clock RE: JavaScript Localtime by Ezra on 04-11-2007 at 02:36 PM
That's easy to find with a quick Google Search code: RE: JavaScript Localtime by Eddie on 04-11-2007 at 02:39 PM ty ezra, but can i have it so its not in a form please RE: JavaScript Localtime by Ezra on 04-11-2007 at 02:48 PM
The example was more of something that you could adapt to your website not just copy/paste RE: JavaScript Localtime by Eddie on 04-11-2007 at 02:50 PM kty RE: JavaScript Localtime by markee on 04-11-2007 at 02:59 PM
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: 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 EDIT3: Had a problem with the year that is now fixed.... why do they start at 1900? RE: JavaScript Localtime by Eddie on 04-11-2007 at 03:33 PM Thanks Markee Appreciated buddy RE: JavaScript Localtime by Matti on 04-14-2007 at 02:05 PM
quote:Why don't you simply use d.getFullYear()? Much easier! |