Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Created October 19, 2010 19:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakebellacera/634904 to your computer and use it in GitHub Desktop.
Save jakebellacera/634904 to your computer and use it in GitHub Desktop.
Quick little function to convert date strings to unix timestamps
// 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