我正在工作的一个MemberMouse订阅Wordpress网站。在特定的用户页面上,我需要显示注册日期的时间加上24小时。例如,如果注册日期是:2017年7月24日下午12:34,我想显示:2017年7月25日下午12:34。
<?php
$datee= date("F j, Y g:i a", strtotime("[MM_Member_Data
name='registrationDate']+ 10 hours"));
?>
Access until: <?php echo $datee; ?>顺便提一下,SmartTag "MM_Member_Data name='registrationDate'“给出的例子是:2017年7月24日下午12:34
我试过上面的代码来获得注册日期,但是得到了错误。
任何解决这一问题的办法都将不胜感激。
谢谢,
阿隆
发布于 2017-07-28 23:59:32
最简单的代码看起来有点像这样,并保持原来的想法,只处理短代码内联。
<?php
$datee= date("F j, Y g:i a", strtotime(do_shortcode("[MM_Member_Data name='registrationDate'] + 10 hours")));
?>
Access until: <?php echo $datee; ?>然而,我更愿意使用干净的方法,并单独完成一些事情(另外:我不知道registrationDate短代码是什么格式。这是unix时间戳还是格式化日期/时间的字符串?)
<?php
// let's assume for a minute that $registrationDate will be a php date aka unix timestamp
// if it's not, you'll have to first run this through strtotime again, i.e.:
// $registrationDate = strtotime(do_shortcode("[MM_Member_Data name='registrationDate']"));
$registrationDate = do_shortcode("[MM_Member_Data name='registrationDate']");
$datee = date("F j, Y g:i a", $registrationDate + 36000);
?>
Access until: <?php echo $datee; ?>https://stackoverflow.com/questions/45379005
复制相似问题