madhu Posted June 7, 2009 Share Posted June 7, 2009 I used the following code snippet and created header.php I used the include option <?php include "header.php"; ?> to to display the date in other page. Yesterday it displayed "Today is June 06, 2009" correctly. But today my system date is June 07 2009. But the pages still display "Today is June 06, 2009". Why it is displaying the old date. Please help me. Code in header.php <div align="center"><font size="4">Welcome to my movie review site!</font> <br> <?php echo "Today is "; echo date("F d"); echo ", "; echo date("Y"); ?> </div> Quote Link to comment Share on other sites More sharing options...
XaeroDegreaz Posted June 7, 2009 Share Posted June 7, 2009 Where is your PHP script being ran? If you are running it from your own computer it should be displaying your date. If you are running it from an external server, it will use that server's date. At the time of writing this, it is still June 6th here in the USA, so if you are being hosted by a USA server, then, that date being displayed is quite correct. Quote Link to comment Share on other sites More sharing options...
madhu Posted June 7, 2009 Author Share Posted June 7, 2009 Thanks XaeroDegreaz for a quick reply. I am running it on my own machine. Not on any external server. Quote Link to comment Share on other sites More sharing options...
madhu Posted June 7, 2009 Author Share Posted June 7, 2009 I also have refresh problem, which i reported under http://www.phpfreaks.com/forums/index.php/topic,255562.0.html Both these are interconnected? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 If you do the following - echo date('Y-m-d H:i:s'); Does the value change when you refresh the page every 1 second? Quote Link to comment Share on other sites More sharing options...
madhu Posted June 7, 2009 Author Share Posted June 7, 2009 When I use echo date('Y-m-d H:i:s'); time is getting refreshed for every refresh I give. But I noticed one strange thing. When my system time is 1:40 PM, the time displayed in the page 5:40 AM (Now the date displayed is June 07, 2009). How come this difference arise ? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 My guess is that your server's timezone is different than the one on your computer. Quote Link to comment Share on other sites More sharing options...
Alex Posted June 7, 2009 Share Posted June 7, 2009 If there's an 8-hour difference and you want it to display your time you can use: date('whatever format', time()+3600*; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.