Jack Pilowsky
Jack Pilowsky

Reputation: 2303

PHP strtotime() different between ('Wednesday') and ('next Wednesday')

The problem I'm having is in trying to look up wednesday of next week.

$next_wednesday = strtotime("next Wednesday 19:00:00"); 
$this_wednesday = strtotime("Wednesday 19:00:00");

The values for $next_wednesday and $this_wednesday come out the same

Upvotes: 0

Views: 792

Answers (4)

May Ann
May Ann

Reputation: 11

    <?php
    $year = 2013;
    $month = 7;
    $day = 5;


    echo date("F j, Y, g:i a",strtotime('next Wednesday')).'<br>';

    echo date("F j, Y, g:i a",strtotime('next 

    Wednesday',mktime(0,0,0,$month,$day,$year)));

   ?>

Upvotes: 1

Amit Garg
Amit Garg

Reputation: 3907

<?php
$this_wednesday = strtotime("Wednesday 19:00:00");
$next_wednesday = strtotime('last Wednesday');

echo date('m/d/y h:i a',$this_wednesday) . "\n" . date('m/d/y h:i a',$next_wednesday);

See the Demo

Upvotes: 1

bansi
bansi

Reputation: 57002

try using more specific texts when using strtotime.

$this_wednesday = strtotime('Wednesday this week 19:00:00');
$next_wednesday = strtotime('Wednesday next week 19:00:00');

Upvotes: 2

Carlos Campderr&#243;s
Carlos Campderr&#243;s

Reputation: 22972

Use

$this_wednesday = strtotime("Wednesday 19:00:00");
$next_wednesday = strtotime("+1 week Wednesday 19:00:00");

Upvotes: 1

Related Questions