Skip to content

Instantly share code, notes, and snippets.

@clarkeash
Created July 29, 2012 22:15
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 clarkeash/3202122 to your computer and use it in GitHub Desktop.
Save clarkeash/3202122 to your computer and use it in GitHub Desktop.
PHP Helper function for converting a timestamp.
<?php
function convert_timestamp($timestamp, $format) {
$exp = explode(" ", $timestamp);
$date = explode("-", $exp[0]);
$year = $date[0];
$month = $date[1];
$day = $date[2];
$time = explode(":", $exp[1]);
$hour = $time[0];
$minute = $time[1];
$second = $time[2];
return date($format,mktime($hour, $minute, $second, $month, $day, $year));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment