Created
October 19, 2010 19:31
-
-
Save jakebellacera/634904 to your computer and use it in GitHub Desktop.
Quick little function to convert date strings to unix timestamps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Function | |
function dateToUnix($time) { | |
return date('U', strtotime($time)); | |
} | |
// Example: | |
// We need to convert a simple string to a UNIX timestamp. | |
$sampleDate = '9/15/2010 05:30'; | |
// Now, put the $sampleDate into the dateToUnix() function. | |
dateToUnix($sampleDate); | |
// => 1284553800 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment