score:0
Can't you just cut of the last 6 chars of that string? You might then round the miliseconds and eventually add a second to you time object.
score:0
This is simpler and in one line:
new Date('01/09/2015 06:16:14.123'.split(".")[0])
score:2
Many ways to Rome. The given code will return '(datestr=) 2011-4-4 19:27:39.92'. Is that what you look for?
var darr = '2011-04-04 19:27:39.92034'.split('.')
, dat=new Date(darr[0])
, datestr = '';
dat.setMilliseconds(Math.round(darr[1]/1000));
datestr = [ [dat.getFullYear(),dat.getMonth()+1,dat.getDate()].join('-')
,' ',
[dat.getHours(),dat.getMinutes(),dat.getSeconds()].join(':')
,'.',
dat.getMilliseconds()
].join('');
score:9
JS built in Date class should be able to handle this, and getTime() can return milliseconds since start 1970 (UNIX time). Watch out for time zone issues though; the constructor may interpret the date/time as being local, but getTime()'s milliseconds since 1970 may be in UTC, baking in a conversion that is difficult to remove.
new Date("2011-04-04 19:27:39.92034").getTime()
1301941659920
Source: stackoverflow.com
Related Query
- Convert from string with milliseconds to date object Javascript
- Rails - convert date string into javascript date object for highcharts
- highcharts: convert useUTC=true milliseconds to javascript Date object
- Highcharts: convert string to an object with javascript
- c# WPF Webbrowser with Highchart, Javascript from external source not working "An error has occurred in the script on this page"
- Convert Javascript Object to array of arrays with two values
- Convert Date to Milliseconds
- Populate Highcharts X-Axis With Dates Given a From And To Date
- How to convert a JavaScript object to array
- How to populate a Highcharts axis with string formatted data from a PHP array
- String with multiple whitespaces on javascript
- Date / Time problem in javascript with highcharts
- passing formatting JavaScript code to HighCharts with JSON
- How to update a Javascript object with a function
- how do you convert epoch to readable date format in javascript
- Array split with the help of object categories values of array- Javascript - High Chart
- How to convert string array to ints to use with Highcharts
- Convert javascript datetime object to the format acceptable by highcharts Date.UTC(2014, 0, 2)
- javascript array object doesn't work with Hicharts when defined through jinja (Django 2.0)
- Prevent from executing previous JavaScript with turbolinks and highcharts //LazyHighCharts
- how to make barchart from date 1 until 31 with different value?
- How to configure date in Grantt chart of (Highcharts) so it accept date in string without javascript date?
- Loading string data from table gets parsed as Date on Chrome - Highcharts
- How filter json data with date from datepicker Angular2 app
- Set HighCharts data from JSON string with setData() function
- Javascript - convert HTML div with SVG to image
- Creating array from javascript object
- How to convert datetime to epoch time in milliseconds javascript
- Pass custom date object from jalali-moment library to time.Date option
- Convert c# date to Javascript
More Query from same tag
- Ionic app doesn't show custom buttons from Highchart library
- Integrate Highcharts maps with react component
- Add 2 legends in one chart
- Angular highchart-ng installation
- How to draw a bar chart that one series has both positive and negative values in Highcharts?
- Highcharts not displaying data at some zoom levels
- How to control HightChart Pie Chart/Donut Chart label font-weight in config
- Cannot get Highcharts solidgauge stops to work in styled mode
- Highcharts - how to export chart with a custom legend?
- Highcharts - with datetime axis labels overlap
- How do I reshape my existing JSON to fit Highcharts
- highcharts. How to determine the coordinates of the point where the CLICK was made?
- How to draw disconnected straight lines over a graph?
- How to correspond tooltip title with the legends at the bottom in Highcharts?
- Highlight Highcharts Organization Chart nodes
- Turning HighChart into a stacked Bar Graph with Title
- Put favicon in middle of Highchart
- Column Chart: Click event to only trigger on drilldown series
- Highcharts series setData from ajax php procedure
- Move the legend a little bit higher
- "The "highcharts" property was not passed" warning with constructorType="chart"
- Highcharts, display marker on selected point only
- Create Phantomjs export server to convert highchart to image base64 string
- Highchart spline Chart with no markers and legends markers as circle's
- Highchart Axis Update/ chart redraw
- HighStock y-axis labels changing by itself when horizontal scroll moves
- How to check if Highcharts y-axis exists
- Highchart: Can I use a different variable as the data labels?
- Ajax Request to Insert Highcharts into Head and Run Function
- Get y point from x given point hightcharts