OnlineSolution Forum IndexOnlineSolution Forum Index
OnlineSolution
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups   Register  Register  
Register::  Log in Log in to check your private messages


 Advertisement

Post new topic  Reply to topic
 [ PHP Q&A ] Incorrrect Local Time « View previous topic :: View next topic » 
Author Message
cutiencoco
PostPosted: Sat Jun 27, 2009 5:25 pm    Post subject: Incorrrect Local Time Reply with quote



Joined: 25 Jun 2009
Posts: 8

I've used idate(),mktime(),time() for return local time, but it always return the wrong hour for me? Can anyone help me?

Code:
<?php
echo(idate("h"));
?>
Back to top
View user's profile Send private message
Paul
PostPosted: Sat Jun 27, 2009 10:29 pm    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

Hi cutiencoco,

have you checked your server/computer's local time?
_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cutiencoco
PostPosted: Sat Jun 27, 2009 11:35 pm    Post subject: Reply with quote



Joined: 25 Jun 2009
Posts: 8

yes ar
the php code shows a different time from my computer (the most right hand bottom corner clock of window vista)
Back to top
View user's profile Send private message
Paul
PostPosted: Sat Jun 27, 2009 11:40 pm    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

Are you running PHP on your local PC or from another computer?

If you running web service from another computer/server, then you'll need to add/subtract time difference between your local time and server time.

This is because local time means local time of the web server, not your own pc.
_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cutiencoco
PostPosted: Sat Jun 27, 2009 11:57 pm    Post subject: Reply with quote



Joined: 25 Jun 2009
Posts: 8

Thank you, Paul.
I use appserv(php and mySQL) to construct my website and run php on my local PC .Could you please tell me how can I do the local time setting in Appserv?
Back to top
View user's profile Send private message
Paul
PostPosted: Sun Jun 28, 2009 12:04 am    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

Are you doing web hosting or server hosting? (ie, do you have SSH root account for your web server?)

If you're doing web hosting then you'll need ask Appserv for the server's local time details because hosting company will only able to change server's local time.

If you have ssh root account, then check your server's local time by using date command from SSH.
_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cutiencoco
PostPosted: Sun Jun 28, 2009 12:10 am    Post subject: Reply with quote



Joined: 25 Jun 2009
Posts: 8

Really thank you for your reply Very Happy
In fact, I don't know what can I do
I am just running localhost
Back to top
View user's profile Send private message
Paul
PostPosted: Sun Jun 28, 2009 12:13 am    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

Sorry, I think I'm bit confused.

If you running from localhost (running webserver with PHP + MySQL from your own PC), double click righthand side clock and double check your time zone.

Timezone might affect your settings.
_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cutiencoco
PostPosted: Sun Jun 28, 2009 12:38 am    Post subject: Reply with quote



Joined: 25 Jun 2009
Posts: 8

do you mean the right hand corner clock of window vista? I've checked it is the right timezone but it still does not work.
Back to top
View user's profile Send private message
Paul
PostPosted: Sun Jun 28, 2009 12:41 am    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

Very strange... shouldn't be happen.

Have you tried date('H')?
_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cutiencoco
PostPosted: Sun Jun 28, 2009 12:55 am    Post subject: Reply with quote



Joined: 25 Jun 2009
Posts: 8

yes, I tired it.
It still gave me the wrong local time.
Anyway, thank you for your help.
Back to top
View user's profile Send private message
Paul
PostPosted: Mon Jun 29, 2009 4:26 pm    Post subject: Reply with quote

Site Admin

Joined: 10 Dec 2007
Posts: 143
Location: New Zealand

I found something different:

Under you PHP.ini, set date.timezone under [Date] section and uncomment it.

For your time zone, follow the link http://www.php.net/manual/en/timezones.php
_________________
Paul KH Kim

http://www.onlinesolution.co.nz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cutiencoco
PostPosted: Tue Jun 30, 2009 7:06 pm    Post subject: Reply with quote



Joined: 25 Jun 2009
Posts: 8

It works! Really thank you for helping me to solve the problem. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

 Sponsor Link

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



OnlineSolution - Since 2007
DAJ Glass (1.0.8) template by Dustin Baccetti
EQ graphic based off of a design from www.freeclipart.nu
Powered by phpBB © 2001, 2005 phpBB Group