Posted By

stancell on 04/21/08


Tagged

date today tomorrow yesterday


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

Wiederkehr
Nix
fackz
joethermal
darkapple


Sample date calculations


 / Published in: PHP
 

Today, tomorrow, yesterday and other date calculations

  1. Today: <?php echo date('Y-m-d') ?> <br />
  2. Tomorrow: <?php echo date('Y-m-d', strtotime('+1 day')) ?> <br />
  3. Yesterday: <?php echo date('Y-m-d', strtotime('-1 day')) ?> <br />
  4. 1 week later: <?php echo date('Y-m-d', strtotime('+1 week')) ?> <br />
  5. 1 month later: <?php echo date('Y-m-d', strtotime('+1 month')) ?> <br />
  6.  
  7. // relative date
  8. 1 day after <?php echo date('Y-m-d', strtotime('+1 day', strtotime($someDate))) ?> <br/>

Report this snippet  

You need to login to post a comment.