What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Help with Local time PHP code

Help with Local time PHP code
Author: Message:
Salem
Senior Member
****

Avatar

Posts: 769
Reputation: 16
37 / Male / Flag
Joined: May 2004
O.P. Help with Local time PHP code
I have used the local time script from Dynamic Drive on a webpage, however, on the page i get NaN:NaN:NaN AM where the time should be (when set to short format).

When using the code i chose the PHP mode as the server supports PHP, but it still doesn't work. If the display format is changed to long then i get undefined instead of the server time.

Any ideas?

Thanks in Advance

This post was edited on 12-30-2005 at 04:06 PM by Salem.
[Image: salem874.smart.jpg][Image: card.png]
Was i Helpful?[/url]
12-30-2005 04:04 PM
Profile PM Find Quote Report
rix
Full Member
***

Avatar

Posts: 483
Reputation: 16
34 / Male / Flag
Joined: Apr 2004
RE: Help with Local time PHP code
I'm not sure, did I understand you correctly, but why don't you just use simple PHP date functions? You can easily show time by doing this:
code:
echo date("H:i:s");

Also take a look at these functions:
date_default_timezone_set()
date_default_timezone_get
date()

This post was edited on 12-30-2005 at 04:16 PM by rix.
Show Plus! your commitment - Support Plus!
:: Plus!'s Estonian community - http://foorum.msgpluslive.ee/ ::
12-30-2005 04:14 PM
Profile E-Mail PM Find Quote Report
Salem
Senior Member
****

Avatar

Posts: 769
Reputation: 16
37 / Male / Flag
Joined: May 2004
O.P. RE: RE: Help with Local time PHP code
quote:
Originally posted by rix
I'm not sure, did I understand you correctly, but why don't you just use simple PHP date functions? You can easily show time by doing this:
code:
echo date("H:i:s");

Also take a look at these functions:
date_default_timezone_set()
date_default_timezone_get
date()


Yeh, but im totally new to PHP. If some can help i'd be very greatful
[Image: salem874.smart.jpg][Image: card.png]
Was i Helpful?[/url]
12-30-2005 04:17 PM
Profile PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: Help with Local time PHP code
Use the date() function to get the server time -> http://uk2.php.net/manual/en/function.date.php

If you want to set the time to a certain place gmstrftime -> http://uk2.php.net/manual/en/function.gmstrftime.php
You change the locale settings to get the what time you want

If you want GMT time use gmmktime -> http://uk2.php.net/manual/en/function.gmmktime.php
[Image: sig.png]
12-30-2005 04:54 PM
Profile PM Web Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
35 / Male / Flag
Joined: Aug 2003
RE: RE: RE: Help with Local time PHP code
quote:
Originally posted by rix
I'm not sure, did I understand you correctly, but why don't you just use simple PHP date functions? You can easily show time by doing this:
code:
echo date("H:i:s");

quote:
Originally posted by Salem
Yeh, but im totally new to PHP. If some can help i'd be very greatful

You must rename your files to something.php, they can't be something.html for PHP to work (except for exceptions). Sorry if you already knew this.

Inside a file called something.php, put this:
code:
<?php
echo date('g:i A');
?>
Wherever in the file you put it, PHP shpuld make it come out like 12:35 PM (the current time).

Instead of g:i A, you can put other things to have the time in a different format. Refer to date in the PHP manual for the parameters you can use.

Though if you are having problems still, maybe the time is not working on the server.
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
12-31-2005 01:44 AM
Profile E-Mail PM Web Find Quote Report
Salem
Senior Member
****

Avatar

Posts: 769
Reputation: 16
37 / Male / Flag
Joined: May 2004
O.P. RE: RE: RE: RE: Help with Local time PHP code
quote:
Originally posted by rav0
You must rename your files to something.php, they can't be something.html for PHP to work (except for exceptions). Sorry if you already knew this.

yes i was aware about this

quote:
Originally posted by rav0
Inside a file called something.php, put this:
code:
<?php
echo date('g:i A');
?>
Wherever in the file you put it, PHP shpuld make it come out like 12:35 PM (the current time).

Instead of g:i A, you can put other things to have the time in a different format. Refer to date in the PHP manual for the parameters you can use.

Though if you are having problems still, maybe the time is not working on the server.


Thanks, this does help.

Will this method constantly update the time, or will it only be accurate on every refresh. The script i tried using updates the time on the webpage constantly.

Salem

This post was edited on 01-01-2006 at 08:21 PM by Salem.
[Image: salem874.smart.jpg][Image: card.png]
Was i Helpful?[/url]
01-01-2006 08:19 PM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Help with Local time PHP code
This will only be accurate on every refresh, this is the way php works.

For realtime accuracy you should use JavaScript or something.
[Image: 1-0.png]
             
01-01-2006 08:49 PM
Profile PM Web Find Quote Report
Salem
Senior Member
****

Avatar

Posts: 769
Reputation: 16
37 / Male / Flag
Joined: May 2004
O.P. RE: RE: Help with Local time PHP code
quote:
Originally posted by Ezra
This will only be accurate on every refresh, this is the way php works.

For realtime accuracy you should use JavaScript or something.


Thanks, yeh i thoguth that would be the case. Thanks for the help guys.
[Image: salem874.smart.jpg][Image: card.png]
Was i Helpful?[/url]
01-01-2006 08:54 PM
Profile PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: Help with Local time PHP code
JS Date -> http://www.w3schools.com/js/js_obj_date.asp

Realtime JS Clock -> http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clock
[Image: sig.png]
01-01-2006 10:26 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


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