Jump to content

mktime()


stijn0713

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336462
Share on other sites

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

?>

Link to comment
https://forums.phpfreaks.com/topic/260752-mktime/#findComment-1336465
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.