se resuelve mi problema mediante la creación de un objeto fecha y dejar que me dan de nuevo la marca de tiempo. Pero para ello es necesario que para convertir la cadena en este formato:
year, month, date, hours, minutes, seconds,ms
un ejemplo sería como:
dateObj = new Date(year, month, date);
timestamp = dateObj.getTime();
Esto funciona salvamento en IE y FF.
IE Dev Center: Date Object (JavaScript)
Mozilla Dev Network: Date
Para su ejemplo lo haría con algo como esto:
//your string
var str = "Fri Jun 11 04:55:12 +0000 2010";
//maps months to integer from 0 to 11
var monthArray = {"Jan":0, "Feb":1, "Mar":2, "Apr":3, "May":4, "Jun":5, "Jul":6, "Aug":7, "Sep":8, "Oct":9, "Nev":10, "Dec":11};
//get the values from the string
var regex = /^[^ ]+ ([^ ]+) (\d{1,2}) (\d{2}):(\d{2}):(\d{2}) \+(\d{4}) (\d{4})$/;
match = regex.exec(str);
var month = monthArray[match[1]],
date = match[2],
hours = match[3],
minutes = match[4],
seconds = match[5],
ms = match[6],
year = match[7];
//create date object with values
var dateObject = new Date(year, month, date, hours, minutes , seconds, ms);
var ts = dateObject.getTime(); //timestamp in ms
¿Pero hay un formato común compatible en todos los navegadores y plataformas? –
Para mí, .toJSON() funciona. Devuelve la fecha en un formato que se ve como 'aaaa-mm-ddTxx.xx'. Lo intenté en IE8 y FireFox 14. – Samuel
o uso [moment.js] (http://momentjs.com/) –