Manhag Posted November 22, 2012 Share Posted November 22, 2012 <?=date('H', ($min));?>; it shows hours in gmt i wana show it depends on machine time any help ? Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/ Share on other sites More sharing options...
Muddy_Funster Posted November 22, 2012 Share Posted November 22, 2012 Try not using short open tags, and using gmdate instead of date : gmdate('H', $min); Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394365 Share on other sites More sharing options...
Manhag Posted November 22, 2012 Author Share Posted November 22, 2012 it shows time in gmt i want it depends on machine time zone did u get it ? Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394368 Share on other sites More sharing options...
Muddy_Funster Posted November 22, 2012 Share Posted November 22, 2012 yip, and when I tested it it worked for me (I am in the uk right enough...). did you try it? Also, where exactly do you think the script is getting it's time zone settings anyway? It's not going off to some NTS and pulling GMT out just to mess with you, it takes the time zone setting as whatever you set it as in the php.ini file. Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394370 Share on other sites More sharing options...
jcbones Posted November 22, 2012 Share Posted November 22, 2012 By "machines timezone" do you mean the client, or the server? Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394380 Share on other sites More sharing options...
mrMarcus Posted November 22, 2012 Share Posted November 22, 2012 You can set the script timezone like so: date_default_timezone_set('America/Toronto'); $timezone = date_default_timezone_get(); echo date('c'); Or you can change your timezone directly in your php.ini which will affect all scripts. See: http://php.net/manual/en/function.date-default-timezone-set.php and List of Supported Timezones Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394387 Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2012 Share Posted November 22, 2012 Try not using short open tags, and using gmdate instead of date : gmdate('H', $min); gmdate() isn't what's needed here: "Identical to the date() function except that the time returned is Greenwich Mean Time (GMT)." Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394388 Share on other sites More sharing options...
Muddy_Funster Posted November 22, 2012 Share Posted November 22, 2012 gmdate() isn't what's needed here: "Identical to the date() function except that the time returned is Greenwich Mean Time (GMT)." I only suggested it because when I tested it on y dev server date() was returing system time +1H, gmdate() returned the actual system time. Quote Link to comment https://forums.phpfreaks.com/topic/271029-show-hours-depends-on-machine-time/#findComment-1394391 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.