function userspecifictime($added_date, $id, $return=true) {
$p_added_date= $added_date;
$scripttag = '<script type="text/javascript">
var dateSR = new Date();
var offsetms = dateSR.getTimezoneOffset() * 60 * 1000;
var serverDate = new Date("'.$p_added_date.'");
serverDate = new Date(serverDate.valueOf() - offsetms);
var hrs = serverDate.getHours();
var mi = serverDate.getMinutes();
var merd = "am";
if(hrs >= 12) {
if(hrs > 12) {
hrs = hrs - 12;
}
merd = "pm";
}
hrs = (hrs < 10) ? "0"+hrs : hrs;
mi = (mi < 10) ? "0"+mi : mi;
ft=hrs+":"+mi+" "+merd;
document.getElementById("'.$id.'").innerHTML = ft;
</script>';
if($return) {
return $scripttag;
} else {
echo $scripttag;
}
}
<?php
<p id="timeid"></p>
$dateInUTC_Format = '2016-06-24 11:43:30';
userspecifictime($dateInUTC_Format,'timeid',false);
?>
$p_added_date= $added_date;
$scripttag = '<script type="text/javascript">
var dateSR = new Date();
var offsetms = dateSR.getTimezoneOffset() * 60 * 1000;
var serverDate = new Date("'.$p_added_date.'");
serverDate = new Date(serverDate.valueOf() - offsetms);
var hrs = serverDate.getHours();
var mi = serverDate.getMinutes();
var merd = "am";
if(hrs >= 12) {
if(hrs > 12) {
hrs = hrs - 12;
}
merd = "pm";
}
hrs = (hrs < 10) ? "0"+hrs : hrs;
mi = (mi < 10) ? "0"+mi : mi;
ft=hrs+":"+mi+" "+merd;
document.getElementById("'.$id.'").innerHTML = ft;
</script>';
if($return) {
return $scripttag;
} else {
echo $scripttag;
}
}
<?php
<p id="timeid"></p>
$dateInUTC_Format = '2016-06-24 11:43:30';
userspecifictime($dateInUTC_Format,'timeid',false);
?>
No comments:
Post a Comment