NYCPHP Meetup

NYPHP.org

[nycphp-talk] simple date arithmetic: days since x

David Mintz dmintz at davidmintz.org
Thu Nov 30 10:41:07 EST 2006


I am having a little trouble thinking this morning. Suppose I just want to
know how many full days have elapsed since October 21, 2006.

$then = mktime(0,0,0,10,21,2006);
$now = time();
$days = floor(($now-$then)/86400);

echo "$days days since 2006-10-21";

Anyone see anything wrong with my reasoning here? This happens to straddle
a seasonal time change, but as I see it, that doesn't matter.

Thanks

---
David Mintz
http://davidmintz.org/

En Nueva York el tránsito de la belleza a la desolación sucede
siempre expeditivamente, como si el principio universal
de máxima eficiencia hubiera aconsejado la supresión de
gradaciones intermedias.

  -- Antonio Muñoz Molina, Ventanas de Manhattan





More information about the talk mailing list