• 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

    (@spotlife)

    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.