Title: php timestamp weekago
Last modified: August 20, 2016

---

# php timestamp weekago

 *  [Tomas](https://wordpress.org/support/users/spotlife/)
 * (@spotlife)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-timestamp-weekago/)
 * Hi, I have a plugin that creates stats. Includes a column with timestamp like:
   
   1350831068
 * I use a function to retrieve last weeks stat by (excerpt):
 *     ```
       $Weekago = time() - (7 * 24 * 60 * 60);
       SELECT COUNT(*) FROM " . $wpdb->base_prefix . $blog_id ."_sessions WHERE timestamp > ". $Weekago
       ```
   
 * Now, I just installed a new stats plugin which has a column (stat_date) and the
   time format like:
    2013-01-30 16:12:43
 *     ```
       $Weekago = time() - (7 * 24 * 60 * 60);
       SELECT COUNT(*) FROM " . $wpdb->base_prefix . $blog_id ."_blogstats WHERE stat_date > ". $Weekago
       ```
   
 * Question: How can I modify “$Weekago” to reflect the different time/date format?
 * Many thanks in advance

Viewing 1 replies (of 1 total)

 *  Thread Starter [Tomas](https://wordpress.org/support/users/spotlife/)
 * (@spotlife)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-timestamp-weekago/#post-3420696)
 * I thing I found a solution:
 * `SELECT COUNT(*) FROM " . $wpdb->base_prefix . $blog_id ."_blogstats WHERE stat_date
   >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)`
 * Would that suffice?

Viewing 1 replies (of 1 total)

The topic ‘php timestamp weekago’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [Tomas](https://wordpress.org/support/users/spotlife/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/php-timestamp-weekago/#post-3420696)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
