I have a somewhat working countdown script already with a defined time (using new DateTime) but haven't figured out how to automatically swap times daily.
I'm looking to do a countdown every day at 5:10, 5:50, and 6:15 PM UTC. If 5:10:00 passes, then swap the countdown for 5:50:00. If it's 6:16, then it'll show for 5:10 tomorrow
How would I be doing comparisons for this? It says something about a non-object when I try to just use the datetime'd variable in a > <
Rather than comparing the objects themselves, you can compare their timestamps. For example:
if($dateTime1->getTimestamp() > $dateTime2->getTimestamp()) {
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.