date - How to get Unix Local Time?

admin2025-06-05  0

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.

Share Improve this question asked Dec 5, 2018 at 5:52 SalSal 1535 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Please 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');
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749127542a316598.html

最新回复(0)