Create a gist now

Instantly share code, notes, and snippets.

[ 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