I've got a timestamp in the following format (Which can easily be changed thanks to the beauties of PHP!).
2011-02-12 14:44:00
What is the quickest/simplest way to check if this timestamp was taken today?
Answer: Use the PHP date() Function You can simply use the PHP date() function to get the current data and time in various format, for example, date('d-m-y h:i:s') , date('d/m/y H:i:s') , and so on.
The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision.
This should solve it: $day = date('D'); $date = date('d') if($day == Mon){ //Code for monday } if($date == 01){ //code for 1st fo the month } else{ //not the first, no money for you =/ }
php // The event date $eventdate = strtotime(get_field('date_time')); // Today's date $today = strtotime('now'); // Tomorrow's date $tomorrow = strtotime('tomorrow'); // If event date is equal to today's date, show TODAY if (date('m-d-Y', $today) == date('m-d-Y', $eventdate)) { echo 'Today'; } // If event date is equal ...
I think:
date('Ymd') == date('Ymd', strtotime($timestamp))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With