• Álvaro González (github)

    Notably, PHP pins the Unix timestamp to UTC+00:00, aka GMT.

    PHP's Unix time is the number of seconds since Unix Epoch, like everybody else.

  • LZ79LRU (unregistered) in reply to Álvaro González

    Yes. But given that this is PHP we are talking about readers would be excused for being surprised about that fact.

  • (nodebb)

    This function has the effect of flooring to second. It's a terrible way to do that, but it's not a no-op.

  • (nodebb)

    So this function takes a time, formats it, parses the format to get what should be the same time back.

    Except when it shouldn't.

    $ cat time.php
    <?php
        $utc_str = gmdate("M d Y H:i:s", time());
        echo strtotime($utc_str) . PHP_EOL;
        date_default_timezone_set('America/New_York'); // or set date.timezone in .htaccess or php.ini
        echo strtotime($utc_str) . PHP_EOL;
    
    $ php -f time.php
    1729079464
    1729093864
    $ 
    

    Of course, changing the default timezone can be a WTF in and of itself...

  • LZ79LRU (unregistered)

    PHP and WTF have the same character count. Coincidence? Or is it maybe inspiration? Could our ancestors have been inspired to create PHP by access to extraterrestrial knowledge? Could its many insane and idiotic idiosyncrasies be nothing but errors in translation resulting from our inability to understand advanced alien programming paradigms?

    See this and more as we reveal the ultimate truth in the next episode of Ancient Programmers.

  • dusoft (unregistered) in reply to LZ79LRU

    LZ79LRU and TROLL do not have he same character count, but they come close.

  • (nodebb) in reply to Mr. TA

    time() returns the time as an integer number of seconds, so it's already floored.

  • TheCPUWizard (unregistered)
    Comment held for moderation.
  • (nodebb) in reply to Barry Margolin

    Interesting, I thought it's usually in milliseconds. Oh well, still a giant WTF.

  • Darren (unregistered)
    Comment held for moderation.
  • löchlein deluxe (unregistered)

    I'd like to take the opportunity to share my favourite atd "feature":

    $ echo '/bin/true' | at now
    job 4 at Thu Oct 17 07:00:00 2024
    $ echo '/bin/true' | at 'Thu Oct 17 07:00:00 2024'
    syntax error. Last token seen: Oct
    Garbled time
    

    Yes, it understands almost any time spec, including "at teatime", but not the one format it emits.

  • (nodebb)

    What this function is returns a new timestamp that forces the epoch to be 1970-01-01 00:00:00 in the current timezone (whatever that has been configured to be). So if your timezone is at UTC-8 then yourTime() (no way is it myTime()) would return a timestamp that is 28800 less than the Unix timestamp.

    In other words: it takes the Unix timestamp, subtracts the current timezone's offset from UTC, and returns the result.

    function myTime() {
        return time() + date('Z');
    }
    

    Addendum 2024-10-17 02:41: Adds, subtracts: depends on which side you're looking at it from.

  • selfdefenseclasses (unregistered)

    "Thank you for sharing this update on the revamped SafetyWing Nomad Insurance claim process! I really appreciate the focus on making it easier and more efficient for travelers. Having reliable and hassle-free insurance is so important for digital nomads, and this is a great step forward. Your post is super helpful!"

    "Thank you for sharing this update on the revamped SafetyWing Nomad Insurance claim process! I really appreciate the focus on making it easier and more efficient for travelers. Having reliable and hassle-free insurance is so important for digital nomads, and this is a great step forward. Your post is super helpful!"

  • Industrial Automation Engineer (unregistered)
    Comment held for moderation.

Leave a comment on “Time to Change”

Log In or post as a guest

Replying to comment #:

« Return to Article