I call a Woocommerce method $order->get_date_created()
that is returning this WC_DateTime
object:
object(WC_DateTime)#26619 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2019-09-06 14:28:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
How can I check if there is more (or less) than 24 hours are gone since the order is made?
2
Answers
Here is the way to check if there is more (or less) than 24 hours passed since an order has been created, using
WC_DateTime
andDateTime
methods on Order created date time:To check if an order was created more than 24 hours ago, you can subtract the current timestamp from the order timestamp and then check if that difference is greater than DAY_IN_SECONDS.