With DateTime objects, you can do it like this:
$date = new DateTime( '2009-10-05 18:07:13' );
$date2 = new DateTime( '2009-10-05 18:11:08' );
$diffInSeconds = $date2->getTimestamp() - $date->getTimestamp();
More Related Contents:
- timestamp within a form [closed]
- Php date() Date and time is stuck [closed]
- Convert from MySQL datetime to another format with PHP
- PHP Sort a multidimensional array by element containing Y-m-d H:i:s date
- How to store repeating dates keeping in mind Daylight Savings Time
- Find difference between two datetimes and format at Y-m-d H:i:s
- PHP DateTime::modify adding and subtracting months
- Get first day of week in PHP?
- MySQL datetime fields and daylight savings time — how do I reference the “extra” hour?
- How to list all months between two dates
- How can I check if the current date/time is past a set date/time?
- get UTC time in PHP
- How to generate random date between two dates using php?
- Check whether the string is a unix timestamp
- How to store NULL values in datetime fields in MySQL?
- How do I deep copy a DateTime object?
- Subtract time in PHP
- Convert UTC dates to local time in PHP
- Set timezone in PHP and MySQL
- NOW() function in PHP
- php strtotime “last monday” if today is monday?
- How to compare two time in PHP
- python format datetime with “st”, “nd”, “rd”, “th” (english ordinal suffix) like PHP’s “S”
- mysql – INSERT date range into date columns IF dates don’t overlap with existing ones
- Using MySQL’s TIMESTAMP vs storing timestamps directly
- Different timezone_types on DateTime object
- Verify valid date using PHP’s DateTime class
- php Object of class DateInterval could not be converted to string
- adding two time values of similar formats using php
- Are PHP DateInterval comparable like DateTime?