如何在 PHP 中将 PHP 时间转换为 Javascript 时间?我的PHP代码:
<?php
$times = array(/* A list of time with "Y-m-d h:i:s" format goes here */);
$return = '[';
$i = 1;
foreach($times as $time) {
$return .= '['.strtotime($time).','.$i.'],';
//In my opinion, converting time to
//js time at here is good choice
if($i==100) {
break;
}
$i++;
}
$return = substr($return, 0, -1).']';
?>
我的脚本:
<script>
var results = [{
label: "Buy in",
data: <?=$return?>
}];
</script>