I want to be able to calculate the days that post was created and compare with today to echo “Today/ Yesterday/ Last Week/ Last Month”. The date format I get from get_the_date() is “December 1, 2015” so I’m wondering if I need to use a different function that I don’t know about.
2 comments
Comments are closed.
You just need to the get_the_date() function;
Now Date Should In YYYY-MM-DD Format
for that
Now use this function
I’m not sure if there is any WordPress function but you can get your values using built in PHP functions.
Yesterday:
Last week
Last month
You can read more about strtotime here http://php.net/manual/en/function.strtotime.php
Here is also a link to the date function, if you havent had any experience with it before: http://php.net/manual/en/function.date.php
You would want to use Y-m-d format for wordpress querys read more about that here: http://php.net/manual/en/function.date.php