stijn0713 Posted April 11, 2012 Share Posted April 11, 2012 My friend a I have to different numbers when we echo mktime(0,0,0,5,12,1990). How is this possible? I thought that only, we you leave some parameters blank, the local this is used, else, it's standardized. thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/ Share on other sites More sharing options...
scootstah Posted April 11, 2012 Share Posted April 11, 2012 I get 642484800. What do you get? Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336452 Share on other sites More sharing options...
PFMaBiSmAd Posted April 11, 2012 Share Posted April 11, 2012 mktime uses your current timezone setting when interpreting the date/time parameters. It will give you the Unix time that date/time occurred at in your timezone. Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336455 Share on other sites More sharing options...
stijn0713 Posted April 11, 2012 Author Share Posted April 11, 2012 I get 642484800. What do you get? I get for example: 642520800 Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336457 Share on other sites More sharing options...
xyph Posted April 11, 2012 Share Posted April 11, 2012 Try setting same time-zones on both machines date_default_timezone_set Unix timestamps are based on the seconds since 1970-1-1 00:00:00 UTC Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336458 Share on other sites More sharing options...
stijn0713 Posted April 11, 2012 Author Share Posted April 11, 2012 unix epoch is January 1 1970 00:00:00 GMT so i thought mktime() will automatically give the seconds in GMT. if i get in well, the interpretation is that, suppose i live in GMT +2, January 1 1970 00;00;00 has occured 2 hours earlier and therefor mktime(0,0,0,12,5,1990) will return 2 hours or 7200 seconds later? I find this strange why it's not standardized. Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336462 Share on other sites More sharing options...
PFMaBiSmAd Posted April 11, 2012 Share Posted April 11, 2012 See: gmmktime Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336463 Share on other sites More sharing options...
xyph Posted April 11, 2012 Share Posted April 11, 2012 unix epoch is January 1 1970 00:00:00 GMT so i thought mktime() will automatically give the seconds in GMT. if i get in well, the interpretation is that, suppose i live in GMT +2, January 1 1970 00;00;00 has occured 2 hours earlier and therefor mktime(0,0,0,12,5,1990) will return 2 hours or 7200 seconds later? I find this strange why it's not standardized. It is standardized. Generally, a programmer won't want a value in GMT time, they'll want it in a specific time-zone. As PFMaBiSmAd pointed out, they have a function to return a Unix time-stamp without an automatic time-zone adjustment being made. <?php date_default_timezone_set( 'America/Vancouver' ); echo mktime(0,0,0,1,1,2000).'<br>'; // 946713600 date_default_timezone_set( 'GMT' ); echo mktime(0,0,0,1,1,2000).'<br>'; // 946684800 echo gmmktime(0,0,0,1,1,2000); // 946684800 ?> Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336465 Share on other sites More sharing options...
stijn0713 Posted April 11, 2012 Author Share Posted April 11, 2012 ok, ty. all set Quote Link to comment https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336467 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.