PHP strtotime()('Wednesday')和('next Wednesday')之间有所不同

时间:2013-06-27 06:22:16

标签: php

我遇到的问题是试图在下周三的星期三看。

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

$next_wednesday$this_wednesday的值相同

4 个答案:

答案 0 :(得分:2)

在使用strtotime时尝试使用更具体的文本。

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

答案 1 :(得分:1)

使用

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

答案 2 :(得分:1)

<?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);

请参阅Demo

答案 3 :(得分:1)

    <?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)));

   ?>