How to get the local PC time regardless the timezone
Moderator: General Moderators
How to get the local PC time regardless the timezone
Hi guys
how could I get the date and time of my pc without considering the timezone ,, since date() function rely on the timezone value that is set by date_default_timezone_set(),, but i need just to get the current time of the pc as it appears in the clock without taking care of the timezone
is there any such function ???
how could I get the date and time of my pc without considering the timezone ,, since date() function rely on the timezone value that is set by date_default_timezone_set(),, but i need just to get the current time of the pc as it appears in the clock without taking care of the timezone
is there any such function ???
-
dgreenhouse
- Forum Newbie
- Posts: 20
- Joined: Tue Mar 10, 2009 5:13 am
Re: How to get the local PC time regardless the timezone
See: localtime() in the PHP manual.
But the timezone still has an effect.
But the timezone still has an effect.
- afr_dnf2011
- Forum Newbie
- Posts: 14
- Joined: Mon Mar 21, 2011 8:20 pm
Re: How to get the local PC time regardless the timezone
If it is only the issue of local pc time then it can be done with javascript.
Re: How to get the local PC time regardless the timezone
thanks dgreenhouse ,, but as u said timezone still has an effect,,
afr_dnf2011,, i need to do it with ONLY PHP
afr_dnf2011,, i need to do it with ONLY PHP
- afr_dnf2011
- Forum Newbie
- Posts: 14
- Joined: Mon Mar 21, 2011 8:20 pm
Re: How to get the local PC time regardless the timezone
If you mean the time on the user's computer, you can't. PHP runs on the server, not on the client. You use Javascript to get the time on the client computer and send it to the server's PHP code. (AJAX would be the easiest way to do it.)
Re: How to get the local PC time regardless the timezone
nop I meant the time of the server itself,, i just run the code on the server there is no client side.
- afr_dnf2011
- Forum Newbie
- Posts: 14
- Joined: Mon Mar 21, 2011 8:20 pm
Re: How to get the local PC time regardless the timezone
Then there is no luck in PHP
. May be this function will be available in later version of PHP. You can also try to implement that function
.
Re: How to get the local PC time regardless the timezone
good idea
thanx for your help
thanx for your help
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to get the local PC time regardless the timezone
It doesn't make sense that you want a datetime without considering timezones. You can't have a time without a timezone.
- afr_dnf2011
- Forum Newbie
- Posts: 14
- Joined: Mon Mar 21, 2011 8:20 pm
Re: How to get the local PC time regardless the timezone
@John really your code is awesome & unique 
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to get the local PC time regardless the timezone
Thanks.. I think?afr_dnf2011 wrote:@John really your code is awesome & unique
What are you referring to?
Re: How to get the local PC time regardless the timezone
Signature, I guess.John Cartwright wrote:What are you referring to?
Re: How to get the local PC time regardless the timezone
Hi Jhon,, thx for ur replyJohn Cartwright wrote:It doesn't make sense that you want a datetime without considering timezones. You can't have a time without a timezone.
My problem is that the time generated from the date() function was changed since the timezone's "time" has been changed (became 1 hr ahead)
I just want a function that takes the time from the pc clock as it is,,
any ways ,, i solved my issue by changing the timezone to the appropriate timezone that give me the correct date