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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.