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

Related Query

More Query from same tag