Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created February 16, 2017 05:52
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 phpfiddle/f5406f95af029bbed211d66051ce6cb2 to your computer and use it in GitHub Desktop.
Save phpfiddle/f5406f95af029bbed211d66051ce6cb2 to your computer and use it in GitHub Desktop.
[ Posted by Bilalsardar ] simple code for converting time to unix time
<?php
$timezone = "Asia/Karachi";
date_default_timezone_set($timezone);
$date = "2017-02-16";
$from_time = "8:00 AM";
$to_time = "10:00 AM";
$fr_time = date("H:i:s", strtotime($from_time));
$t_time = date("H:i:s", strtotime($to_time));
$from_gmt = $date . " " . $fr_time . " " . "GMT+5";
$from_unix = strtotime($from_gmt) . "000";
$to_gmt = $date . " " . $t_time . " " . "GMT+5";
$to_unix = strtotime($to_gmt) . "000";
echo $from_unix;
echo "<br>";
echo $to_unix;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment