Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if timestamp is today

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?

like image 607
Web_Designer Avatar asked Apr 25 '11 04:04

Web_Designer


People also ask

How do you check the date is today or not in PHP?

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.

What is timestamp to date?

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.

How can I tell if PHP is today is Monday?

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 =/ }

How can I get tomorrow date in PHP?

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 ...


1 Answers

I think:

date('Ymd') == date('Ymd', strtotime($timestamp)) 
like image 182
Rudie Avatar answered Oct 21 '22 22:10

Rudie