Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于日期格式的php日期组件(';j F Y';)_Php_Wordpress_Datetime_Advanced Custom Fields - Fatal编程技术网

用于日期格式的php日期组件(';j F Y';)

用于日期格式的php日期组件(';j F Y';),php,wordpress,datetime,advanced-custom-fields,Php,Wordpress,Datetime,Advanced Custom Fields,我有两个约会: $today = date('j F Y'); $display_until = date('j F Y'); ($display_,直到技术上来自ACF字段日期选择器): 我目前正在使用: <?php if($today < $display_until) : ?> *where the magic should happen* <?php endif; ?> *魔法应该发生在哪里* 但它并没有像预期的那样划分事件。。。有人能给我

我有两个约会:

$today = date('j F Y');
$display_until = date('j F Y');
($display_,直到技术上来自ACF字段日期选择器):

我目前正在使用:

<?php if($today < $display_until) : ?>
    *where the magic should happen*
<?php endif; ?>

*魔法应该发生在哪里*

但它并没有像预期的那样划分事件。。。有人能给我指出正确的方向吗?

根据您的评论的进一步解释,您可以使用php函数将任何日期(如字符串)转换为时间戳,然后您可以将此时间戳传递给
date
函数,以获得所需格式的日期

以下是代码:

日期('j F Y',标准时间('2017-05-01')

如果要进行比较,则:

if(strtotime('Jul 10, 2017') < strtotime('+10 days')) {
    // Your logic
}
if(strotime('2017年7月10日')

您也可以使用较新的对象。

从您的注释中进一步解释,您可以使用php函数将任何日期(如字符串)转换为时间戳,然后您可以将此时间戳传递给
date
函数,以获得所需格式的日期

以下是代码:

日期('j F Y',标准时间('2017-05-01')

如果要进行比较,则:

if(strtotime('Jul 10, 2017') < strtotime('+10 days')) {
    // Your logic
}
if(strotime('2017年7月10日')
您还可以使用更新的对象。

您有两种解决方案:

1. 将日期转换为时间戳,然后进行比较:

$today = date('j F Y');
$display_until = date('j F Y');

if (strtotim($today) < strtotime($display_until)){
 //
}
您有两种解决方案:

1. 将日期转换为时间戳,然后进行比较:

$today = date('j F Y');
$display_until = date('j F Y');

if (strtotim($today) < strtotime($display_until)){
 //
}

您应该将它们转换为历元时间戳,然后它只是两个整数。或者,这是我的想法。请发布代码,其中
$today
$display\u,直到处理了
变量。请解释一下你想要实现什么?@Stender-我会使用类似于
$dt_today=new DateTime($today)的东西吗
您可能想看看官方版本中日期函数的第二个参数。您应该将它们转换为历元时间戳,然后它就是两个整数。或者,这就是我的想法。请发布
$today
$display\u中的代码,直到处理了
变量。请解释一下你想要实现什么?@Stender-我会使用类似于
$dt_today=new DateTime($today)的东西吗您可能想看看official中日期函数的第二个参数。