Pro Yearly is on sale from $80 to $50! »

A Tale about Time - LaravelLive India 2018

A Tale about Time - LaravelLive India 2018

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!

39eb3f3d313b13f05534e496285040b8?s=128

Hannes Van De Vreken

March 17, 2018
Tweet

Transcript

  1. A Tale about Time @hannesvdvreken @laravellivein

  2. Hi, my name is Hannes.

  3. !

  4. None
  5. None
  6. A Tale about Time

  7. 2018-03-17T10:15:00+05:30

  8. None
  9. None
  10. None
  11. EST = UTC-05:00

  12. UTC+05:45

  13. UTC+05:30

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

    Sunrise: 6:08 - 6:12 Sunset: 18:16 - 18:19
  15. None
  16. EST/EDT - March 12 CET/CEST - March 24

  17. '

  18. (

  19. )

  20. Storing vs Expressing time

  21. 6:00PM vs 18:00

  22. 1521261900

  23. 1521261900 >1970-01-01T00:00:00+00:00

  24. 1521261900 >1970-01-01T00:00:00+00:00 <2038-01-19T03:14:07+00:00

  25. RFC3339: 2018-03-17T10:15:00+05:30

  26. RFC3339 extended: 2018-03-17T10:15:00.000+05:30

  27. Sortable: 2018-03-17T05:45:00.000+00:00

  28. Calendars

  29. Weeks - 7 days

  30. Months Lunar vs Tropical

  31. Years Lunisolar vs Tropical

  32. 2018AD 1500BC

  33. Leap years

  34. Leap years Leap seconds

  35. Time in PHP

  36. DateTimeInterface - DateTime (date, time, tz) - DateTimeImmutable

  37. $date = $date->setTimezone(‘Asia/Kolkata');

  38. $date = DateTimeImmutable::createFromMutable($mutable);

  39. Change in PHP 7.1: microseconds

  40. // Magic $date = new DateTimeImmutable(‘now’); $date = $date->modify(‘first day

    of next month’);
  41. “now + 5 hours” “first day of next month” "first

    weekday” …
  42. “2016-03-00” → “2016-02-29” “2018-06-31” → “2018-07-01” …

  43. “69-12-31” → “2069-12-31” “70-01-01” → “1970-01-01” …

  44. nesbot/carbon - Mutable cakephp/chronos - Immutable

  45. interface Clock { public function now(): DateTimeImmutable }

  46. The future

  47. E=mc²

  48. c ~ 299.000.000m/s

  49. None
  50. None
  51. Wrapping up

  52. Thanks for your time! @hannesvdvreken @laravellivein

  53. Time for questions. @hannesvdvreken @laravellivein