Linked Questions
32 questions linked to/from How do I compare two DateTime objects in PHP 5.2.8?
1 vote
2 answers
15k views
how to compare two timestamps in PHP? [duplicate]
In my code I've a scenario like this : <?php $start = "03:00:00:am"; $end = "08:00:00:pm"; if($start > $end) {} ?> I tried with unix timestamp but it didnt worked.
-3 votes
3 answers
13k views
compare two DateTime Objects [duplicate]
actually I have 2 DateTime objects $d1 = new DateTime('04/14/2013 8.00 AM'); $d2 = new DateTime('04/14/2013'); so without doing any changes to these 2 objects. is it possible equal these 2 objects.
0 votes
2 answers
2k views
PHP - Changing date's year to current year [duplicate]
I have a couple of date times : DateTime {#2205 ▼ +"date": "1970-01-01 12:30:00.000000" +"timezone_type": 3 +"timezone": "UTC" } DateTime {#2206 ▼ +"date": "1970-01-01 20:00:00.000000" +"...
0 votes
1 answer
124 views
How to print a message if the target time is less than the current time in PHP [duplicate]
I am trying to pass a message if the set time has passed. I have two variables the $date1 which is the current time and the $date2 which is the target time. The third variable $interval is the ...
-2 votes
1 answer
54 views
Compare date string from API [duplicate]
From an API call i get the following date I suppose as a string format : [end_date] => 2018-09-20 Now I have my own created date in my PHP script: $date = '2017-09-20'; Now I want to check if ...
1 vote
0 answers
49 views
I want result in hours between two datetime [duplicate]
Here, I want to get hours between two dates. If I subtract time between two dates, I want 23 hours in a result. My field's datatype is as datetime. My code is like, $usr_check_login = $this -> ...
0 votes
0 answers
32 views
Form calculation fails [duplicate]
We're trying to fix the PHP code (from php programmer who was fired few weeks ago) to make sure these dates does not exceed more than 28 days on the form. When the customer fills out the application ...
161 votes
13 answers
321k views
Compare current date as Y-m-d against Y-m-d string which doesn't have zero padded days
How can I compare two dates in PHP? The date is stored in the database in the following format 2011-10-2 If I wanted to compare today's date against the date in the database to see which one is ...
129 votes
4 answers
246k views
How can I check if the current date/time is past a set date/time?
I'm trying to write a script that will check if the current date/time is past the 05/15/2010 at 4PM How can I use PHP's date() function to perform this check?
12 votes
5 answers
29k views
PHP: How to compare a time string with date('H:i')?
I have time saved in database like 7:30pm as a varchar field. I want to check if this time is greater than time right now or not. I converted the DB time string into '19:30' and now I want to do ...
0 votes
4 answers
10k views
Start Date and Start Time Less than End Date and End Time Validation
Start Time, End Date and End Time variables. The Date Variables are formatted yyyy-mm-dd The Time Variables are formatted hh-mm (however only on hour numbers are usable, e.g Minutes is always 00) ...
4 votes
4 answers
8k views
PHP: Check if DateTime isn't expired
I have a DateTime Object which holds an past timestamp. I would now like to check if this DateTime is older than for example 48Hours. How can I compore them best? Regards EDIT: Hi, thanks for the ...
0 votes
2 answers
2k views
Calculate time difference between pm to am and check if it is in the current time range
Hello i want to check if the current time is between two time range and calculate the difference between them, so far i have this but its not working $current_time = "11:14 pm"; $start_time = "11:00 ...
0 votes
3 answers
1k views
Verifying age on PHP
I've looked at many posts on here and I still cant figure this out. I am trying to verify that someone is older than 13 before they register for my site. This is what i have so far <?php if (...
1 vote
1 answer
809 views
PHP 5.2.9 equivalent of this function
I have this code in php that I could not run in PHP 5.2.9 please give me an Idea to convert this code to work on PHP 5.2.9 Thanks, $startTime = new DateTime(date('h:i:s a')); $endTime = new DateTime("...