Ok, so I have tried all sorts of thing without getting the result I wanted
I have a sql database filled with timestamps (and data) that needs to get plotted in a highchart
Seems I need to convert it to a javascript timestandard, in milliseconds sinds 1 jan 1970
My database timestamp format looks like this " 2014-07-14 03:37:28 " and needs to get to the javascript format
I'm using a piece of php code to extract the data from the database and trow out a json format of the data, but would love some help on how to convert the string into the timestamp i need for the graph, preferably in php.
Hope someone can help me out here
this is the php code used
The propiest that comes to my mind is to create a Date objet with something like:
var str_date = "2014-07-14 03:37:28";
var year = str_date.substring(0,4);
var month = ...;
var day = ...;
var hours = ...;
var minutes = ...;
var seconds = ...;
var your_date = new Date(year, month-1, day, hours, minutes, seconds, milliseconds);
I let you fill the "..." I think you get the idea. Be careful with the months, they start from 0.
Hoped it helped!
1st you want to change date and time to timestamp by this
$utime = strtotime(date($db_date));
2nd take the date value and inserted as a js var
var jsdate = '<?php echo $utime?>';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.