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

A Tale about Time - PHP Limburg

A Tale about Time - PHP Limburg

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

December 05, 2019
Tweet

More Decks by Hannes Van De Vreken

Other Decks in Programming

Transcript

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

    Sunrise: 6:08 - 6:12 Sunset: 18:16 - 18:19
  2. $

  3. %

  4. &

  5. '

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

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

    implements Clock class TestClock implements Clock