0

I'm looking to get Jetpack stats for yesterday, but am having trouble figuring out how to get yesterday from stats_get_csv.

stats_get_csv has two seemingly relevant parameters, "days" which says how many days to go back, and "end" which says what day to end on. So the obvious parameters would be to use yesterday as the "end" on a two-day search. But this is just showing everythingm including the current day's stats.

$yesterday =  date('Y-m-d',strtotime('yesterday'));
$top_posts_yesterday = stats_get_csv('postviews', 'days=2&limit=12&date=' . $yesterday);

specifically, these parameters doesn't get me yesterday (on Feb 12):

days=2&date=2019-02-11

What am I doing wrong?

UPDATE: I was doing two things wrong: first, the "date" attribute there should be "end". Second, "days" is calculated from "end" backwards, not from the current day.

  • Will try using array args instead! Thank you. I had introduced the space in posting it here, so it's not that. – Rob Feb 13 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.