Sample date calculations


/ Published in: PHP
Save to your folder(s)

Today, tomorrow, yesterday and other date calculations


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.