heshan Posted August 2, 2010 Share Posted August 2, 2010 Hi all, I want to include the date and time in the web page to display when a user logged into the site. I found a code.I want to know how it could modify with relevant to our local time? <?php $today = date("d M Y h:i A"); echo $today ?> Thanks, Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 2, 2010 Share Posted August 2, 2010 It is using whatever time is set on the server that the PHP script is running on. To adjust it, you can pass a timestamp to the function with an adjusted interval: date('d M Y h:i A', strtotime('+3 hours')); [/code] http://us3.php.net/manual/en/function.date.php Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted August 2, 2010 Share Posted August 2, 2010 Yes, or: http://us3.php.net/manual/en/function.date-default-timezone-set.php Quote Link to comment Share on other sites More sharing options...
heshan Posted August 2, 2010 Author Share Posted August 2, 2010 Thanks, it works...... :D Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 3, 2010 Share Posted August 3, 2010 If you are going to supply timezone offsets you'd be best of using gmdate and then supplying the users timezone offset to that. Quote Link to comment Share on other sites More sharing options...
Cobalt-Phoenix Posted August 3, 2010 Share Posted August 3, 2010 Here is how I would do it. <?php date_default_timezone_set ("America/New_York"); // set the default timezone $today = date("d M Y h:i A"); echo $today ?> To view supported time zones, refer to: http://php.net/manual/en/timezones.php Alternatively, you can also set the default time zone in your php.ini file if you have access to it. Quote Link to comment Share on other sites More sharing options...
heshan Posted August 13, 2010 Author Share Posted August 13, 2010 Thanks everyone, i got it 8) :D 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.