Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Tale about Time - PHP.gent

A Tale about Time - PHP.gent

Timezones, DST, human readable diffs, standardised formats, intervals, getting the last Tuesday of next month… Dealing with timestamps seems easy, but there’s a lot to it. It’s very easy to do it wrong. Learn how to do this properly and you’ll never be chasing weird time related bugs anymore!

Hannes Van De Vreken

September 19, 2018
Tweet

More Decks by Hannes Van De Vreken

Other Decks in Technology

Transcript

  1. !

  2. Helsinki Sunrise: 9:24 - 3:54 Sunset: 15:13 - 22:50 Quito

    Sunrise: 6:08 - 6:12 Sunset: 18:16 - 18:19
  3. (

  4. )/*

  5. // <7.1 $date = new DateTimeImmutable(‘now’); $date->format(‘u’); // 00000 //

    7.1+ $date = new DateTimeImmutable(‘now’); $date->format(‘u’); // actual microsecond info
  6. interface Clock { public function now(): DateTimeImmutable } class SystemClock

    implements Clock class TestClock implements Clock