[英]how to display the last five hours time from current time(hh:mm ) 12 hour format in high charts?
i am new to high charts and UI side development, i need to display the chart with last five hours on x-axis from current time in 12 hour format. 我是高级图表和UI方面开发的新手,我需要以12小时格式在当前时间的x轴上显示最近五个小时的图表。 please share your suggestion or jsfiddle here
请在这里分享您的建议或jsfiddle
Return the number of milliseconds since 1970/01/01: 返回自1970/01/01以来的毫秒数:
var d = new Date();
var n = d.getTime();
The result of n could be: n的结果可能是:
1460565067992
Then we substract 5 hours in milliseconds 然后我们以毫秒为单位减去5个小时
var x= n-18000000
and we instantiate a new Date object based on this value 然后根据该值实例化一个新的Date对象
var lastFiveHours = new Date(x)
var d = new Date(); var n = d.getTime(); console.log("Current date" + d); $("#currentDate").html(d); var x= n-18000000 var lastFiveHours = new Date(x) console.log("Current date - five hours" + lastFiveHours); $("#currentDateFiveH").html(lastFiveHours);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="currentDate"></div> <div id="currentDateFiveH"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.