Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Problem with date and time in php

 
webmaster forum
Activity
0%
 
New Poster
Posts: 13
Topics: 8
October 06, 2008, 11:26:24 PM

I have a problem about the date and time
so i need a guidance from expert about the php date

Here is my php code

echo date('Y-m-d H:i:s A');

the o/p=> 2008-10-04 06 :12:21 AM

but on my local machine the time is 11:48 AM.

why this difference is it related with time zone ?
any changes I have to made ?

please advise me on this  sad2
 
webmaster forum
greatjoe  Offline
Activity
0%
 
New Poster
Posts: 4
Topics: 2
October 07, 2008, 08:32:58 AM

As far as i know, PHP used UTC timezone to show the date..

And to see the timezone that your PHP version used you can open phpinfo, then you can refer to "Default timezone"
the default timezone is UTC.. UTC is Coordinated Universal Time, GMT is Greenwich Mean Time... both are the same..

example : Los Angeles, California, United States: UTC−8
                Sydney, Australia: UTC+10

to refer more about GMT  you can visit : http://en.wikipedia.org/wiki/Timezone

ps . if you want to show date that reside in your local machine, you can use Javascript ( CMIIW )
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
October 09, 2008, 04:01:54 AM

Does it? I honestly dont know, and you may be correct - does PHP convert the webservers time into GMT, or does it just return the webservers time (which maybe the admin would normalise into GMT?)

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
webmaster forum
Activity
0%
 
New Coder
Posts: 26
Topics: 12
January 21, 2009, 04:37:12 AM

You can use this:

Code:
$newtime = time() + (Hr *Min *Sec);
echo ".date("").";
echo ".date("D d M y - h:i:s a",$newtime).";

for your timezone must be:

Code:
$newtime = time() + (-1 *60 *60);
echo ".date("").";
echo ".date("D d M y - h:i:s a",$newtime).";

and your problem will be solved...
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 05, 2012, 03:11:41 PM