Baoky chen
Baoky chen

Reputation: 99

PHP get next wednesday of a specific date

$wed_date = strtotime('next wednesday');

$my_time = $some_unix_time; 

//how do I get this line below to work
$the_next_wednesday_from_my_time = "";

e.g I want to know from a unix time, the next wednesday is when, how do I achieve it :)

Thanks for helping

Upvotes: 0

Views: 557

Answers (1)

motanelu
motanelu

Reputation: 4025

Try this:

$currentDate   = time();
$nextWednesday = strtotime('next wednesday', $currentDate);

echo date('d-m-Y', $nextWednesday);

strtotime takes a second parameter which is the starting time. See https://php.net/manual/ro/function.strtotime.php

Upvotes: 3

Related Questions