Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Created March 15, 2014 03:15
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 joseluisq/9561383 to your computer and use it in GitHub Desktop.
Save joseluisq/9561383 to your computer and use it in GitHub Desktop.
Change format from string datetime
<?php
/**
* Change format from the datetime
* Example: changeDatetimeFormat('2014-11-02 09:11:00', 'd/m/Y H:i:s a');
*
* @param string $datetime String datetime
* @param string $format String datetime format
* @return string
*/
function changeDatetimeFormat($datetime, $format = 'Y-m-d H:i:s') {
return date($format, strtotime($datetime));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment