Skip to content

Instantly share code, notes, and snippets.

@ptz0n
Created November 13, 2011 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptz0n/1362197 to your computer and use it in GitHub Desktop.
Save ptz0n/1362197 to your computer and use it in GitHub Desktop.
Seconds since midnight to date
<?php
/**
* Seconds since midnight to date
*
* @param string $date
* @param int $seconds
*
* @return string
*/
function secondsSinceMidnightToDate($date, $seconds)
{
return date('c', strtotime($date) + $seconds);
}
var_dump(secondsSinceMidnightToDate('2011-12-19', 80580));
@ptz0n
Copy link
Author

ptz0n commented Nov 13, 2011

Output:

string(25) "2011-12-19T22:23:00+01:00"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment