admin管理员组文章数量:1130349
I have a given time and I'd like to confirm that is AFTER the current time.
$expires_epoch = strtotime($_POST['expiry']);
if($expires_epoch < current_time('mysql')){
...do stuff...
This snippet only works if I set my server to match my local time. That is to say that it's working in UTC time. Any ideas on what to fix? I've tried many alternative to current_time.
I have a given time and I'd like to confirm that is AFTER the current time.
$expires_epoch = strtotime($_POST['expiry']);
if($expires_epoch < current_time('mysql')){
...do stuff...
This snippet only works if I set my server to match my local time. That is to say that it's working in UTC time. Any ideas on what to fix? I've tried many alternative to current_time.
1 Answer
Reset to default 0Please use DateTime::getTimestamp() that returns unix timestamp.
If you want to format the date according to your time zone then you try this.
$datetime = new DateTime("now", new DateTimeZone('America/New York'));
echo $datetime ->format('m/d/Y, H:i:s');
I have a given time and I'd like to confirm that is AFTER the current time.
$expires_epoch = strtotime($_POST['expiry']);
if($expires_epoch < current_time('mysql')){
...do stuff...
This snippet only works if I set my server to match my local time. That is to say that it's working in UTC time. Any ideas on what to fix? I've tried many alternative to current_time.
I have a given time and I'd like to confirm that is AFTER the current time.
$expires_epoch = strtotime($_POST['expiry']);
if($expires_epoch < current_time('mysql')){
...do stuff...
This snippet only works if I set my server to match my local time. That is to say that it's working in UTC time. Any ideas on what to fix? I've tried many alternative to current_time.
1 Answer
Reset to default 0Please use DateTime::getTimestamp() that returns unix timestamp.
If you want to format the date according to your time zone then you try this.
$datetime = new DateTime("now", new DateTimeZone('America/New York'));
echo $datetime ->format('m/d/Y, H:i:s');
本文标签: dateHow to get Unix Local Time
版权声明:本文标题:date - How to get Unix Local Time? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749127503a2320029.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论