sungpeng Posted June 17, 2009 Share Posted June 17, 2009 <?php echo date("l dS of F Y h:i:s A"); Hi good day, check with all of you how to display local singapore time instead of foreign time? Quote Link to comment Share on other sites More sharing options...
xcoderx Posted June 17, 2009 Share Posted June 17, 2009 That code wil only display server time if im not wrong, so to set ur own country time u must use other code Quote Link to comment Share on other sites More sharing options...
sungpeng Posted June 25, 2009 Author Share Posted June 25, 2009 Check which code to recommend to show local singapore time? Quote Link to comment Share on other sites More sharing options...
Alex Posted June 25, 2009 Share Posted June 25, 2009 Find out how off that time is compared to what you want. Then just set an off set based on that. Say it's 1 hour ahead of what you want, you'd do: echo date("l dS of F Y h:i:s A", time()-3600); Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 25, 2009 Share Posted June 25, 2009 You can set the timezone that php uses - http://us.php.net/manual/en/datetime.configuration.php#ini.date.timezone Quote Link to comment Share on other sites More sharing options...
sungpeng Posted June 25, 2009 Author Share Posted June 25, 2009 Thank Quote Link to comment Share on other sites More sharing options...
sungpeng Posted June 25, 2009 Author Share Posted June 25, 2009 date_default_timezone_set('Asia/Singapore'); $time=date('D,F j, Y, H:i:s A'); $insert_student=mysql_query("insert into listings (listdate) values ('$time')"); The setting for "listdate" field is datetime. Can I know how what should I input "default" in mysql? $time=date('D,F j, Y, H:i:s A'); Check also how to make it 24 hours. I find it difficult to insert into mysql the PM & AM if listdate setting is datetime default is 0000-00-00 00:00:00 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 25, 2009 Share Posted June 25, 2009 The format of a DATETIME field is YYYY-MM-DD HH:MM:SS. There are two main reasons for that format - 1) The amount of storage used by a DATETIME has been optimized and it only takes 8 bytes. The format used by date('D,F j, Y, H:i:s A') takes around 31 bytes. This also means that queries involving a DATETIME value are optimized to execute as quick as possible. 2) Dates in the format YYYY-MM-DD can directly be sorted and compared. You would produce values using date('Y-m-d H:i:s'). You can also set the timezone that the mysql server uses for your connection and use the mysql NOW() function in your query to give the same results. See the 'Per-connection time zones' section at this link - http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html To format a DATETIME field when you SELECT it, use the mysql DATE_FORMAT() function - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format 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.