RU beehive logo ITEC dept promo banner
ITEC 325
2014fall
ibarland

homelectshws
D2Lbreeze (snow day)

lect09-dates
times and dates


File timestamps

When looking at files, it can be nice to include their most recent modification time.

Before calling filemtime (which takes in a file-name, and returns a date):

  ; Either:
  ini_set('date.timezone','America/New_York');
  date_default_timezone_set('America/New_York');

  echo strtotime('2012-Feb-08 11:03:27');   // don't use '2012.Feb.08 ...'; it returns null.
  echo date('Y-M-d H:m:s',234234234);

Date representaiton

How are dates stored internally? Try Excel: put dates in A1, A2 (using the `date` function). Note formatting is just the `toString` on top of the underlying date-object.

Try: =A1+3 =A1-A2 =max(A1,A2) That's Cool! This is not: =A1+A2 =A1*7 So, how are dates stored internally? Try formatting the value differently. So, What is the start of the epoch? Try entering 0, and then format it!

Note that time-zone is *only* needed for `toString`, and for parsing -- alternately: for how we speak and read dates when too lazy to include the time-zone. It becomes confusing since we rely on external state (our geographic location). If this location isn't clear (e.g., where *is* the server that is serving this page?), then we have problems. But The time-since-epoch itself is unambiguous. [um, mostly] What about daylight savings time? It's not that *time* jumps ahead from 01:00 to 02:00 and that 01:30 doesn't exist that day; it's that 01:00 we all decide to switch from writing/reading one time-zone and use another; if people are lazy and not including the time-zone then it becomes confusing. Really, "01:30 EDT" and "01:30 EST" are both valid times, and EDT *exists* all year round; it's just that folk around here don't use it for 6mos at a time (and, folk around here *never* speak in PST, even though that time-zone always exists too). ...You change most time-zones by travelling geographically, "through space". You change daylight-savings-time-zones by travelling through time.

homelectshws
D2Lbreeze (snow day)


©2014, Ian Barland, Radford University
Last modified 2014.Sep.18 (Thu)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.