Skip to content

Instantly share code, notes, and snippets.

@ryanmerritt
Created September 18, 2012 10:22
Show Gist options
  • Save ryanmerritt/3742464 to your computer and use it in GitHub Desktop.
Save ryanmerritt/3742464 to your computer and use it in GitHub Desktop.
<?php
$d = new DateTime();
echo $d->format("r\n");
//OUT: Wed, 06 Jul 2011 17:31:13 -0400
$d->setTime(0, 0, 0);
$mt = clone $d;
echo $mt->format("r\n");
// OUT: Wed, 06 Jul 2011 00:00:00 -0400
$my = clone $d;
echo $my->modify('-1 day')->format("r\n");
// OUT: Tue, 05 Jul 2011 00:00:00 -0400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment