searls03 Posted August 10, 2012 Share Posted August 10, 2012 why does everytime I use the php date function after 6 PM central time, it thinks it is the next day....I just use the day part of it, and it now thinks it is the 10 instead of 9 Link to comment https://forums.phpfreaks.com/topic/266887-php-date/ Share on other sites More sharing options...
Christian F. Posted August 10, 2012 Share Posted August 10, 2012 The server is running on a different time zone than yours. Check out "date_default_timezone_set ()" Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368254 Share on other sites More sharing options...
searls03 Posted August 10, 2012 Author Share Posted August 10, 2012 but how come a timestamp inserts correctly then....isn't that part of the server? Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368264 Share on other sites More sharing options...
searls03 Posted August 10, 2012 Author Share Posted August 10, 2012 How exactly do I incorporate with this piece of code? $month = date("F Y"); $day = date("d"); $year = date("Y"); $date = date("Y-m-d"); I am looking and can't quite figure it out.... Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368267 Share on other sites More sharing options...
scootstah Posted August 10, 2012 Share Posted August 10, 2012 <?php date_default_timezone_set('America/Los_Angeles'); $month = date("F Y"); $day = date("d"); $year = date("Y"); $date = date("Y-m-d"); Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368278 Share on other sites More sharing options...
MMDE Posted August 10, 2012 Share Posted August 10, 2012 Can't you set it in the php.ini file? The timezone I mean, if that is the problem. Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368297 Share on other sites More sharing options...
Christian F. Posted August 10, 2012 Share Posted August 10, 2012 Unix timestamps are always UTC (GMT+0), it's when you convert them to an actual date that you want to take the different timezones into consideration. Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368344 Share on other sites More sharing options...
scootstah Posted August 10, 2012 Share Posted August 10, 2012 You can use gmdate if you don't want to take the timezone into consideration. Link to comment https://forums.phpfreaks.com/topic/266887-php-date/#findComment-1368356 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.