We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

gdonald on 09/27/06


Tagged

date days ago


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

vali29


php days ago date


Published in: PHP 


  1. function daysAgo( $days )
  2. {
  3. return date( 'YmdHis', mktime( date( 'H' ),
  4. date( 'i' ),
  5. date( 's' ),
  6. date( 'm' ),
  7. date( 'd' ) - $days,
  8. date( 'Y' ) ) );
  9. }

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: tylerhall on September 27, 2006

Or perhaps...

function daysAgo($n) { return date("YmdHis", time() - 86400 * $n); }

You need to login to post a comment.