I want to calculate a future date based on the date the post is published and use it in the content of a post.
I can echo the post publication date using:
echo the_date('Y-m-d');
How can I calculate the future date?
try
$future_timestamp = strtotime('+1 week', get_the_date('Y-m-d')); echo date('Y-m-d', $future_timestamp);
or
$future_timestamp = get_the_date('U') + (60 * 60 * 24 * 7); echo date('Y-m-d', $future_timestamp);
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the privacy policy and terms of service.
tagged
asked
1 year ago
viewed
74 times
active
Get the weekly newsletter!
see an example newsletter
By subscribing, you agree to the privacy policy and terms of service.