WordPress.org

Ready to get started?Download WordPress

Forums

php timestamp weekago (2 posts)

  1. Tomas
    Member
    Posted 1 year ago #

    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

  2. Tomas
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic