Take the 2-minute tour ×

I'm querying vimeo's API to get the uploaded date of my videos. I'm wondering why this works in chrome, but not safari, and what the proper way to create a time stamp for this video is:

  var vimeoDate = videos[i].upload_date;
  var vidDate = new Date(videos[i].upload_date);
  var vidTime = vidDate.getTime();

  console.log('vimeoDate: ' + vimeoDate + ', ' + vidDate + ', ' + vidTime);
  //returns: "vimeoDate: 2012-06-07 13:47:08, Invalid Date, NaN"

You can see a JSFiddle which returns invalid date here:


To simplify this, you can simply take this string: and run it in safari and it fails:

console.log(new Date('2013-01-02 13:33:51'));


share|improve this question
try: console.log('vimeoDate: ' +(typeof vimeoDate) +', ' + vimeoDate + ', ' + vidDate + ', ' + vidTime);. Maybe it is actually a date. –  algorhythm Jan 14 '13 at 11:27
typeof vimeoDate returns string –  mheavers Jan 14 '13 at 11:34
then it should work... are you serious, that all elements in your array returns string? give some more code or make a jsfiddle.net that behaves like this. –  algorhythm Jan 14 '13 at 11:36
JS Fiddle: jsfiddle.net/nPSqL - returns Invalid Date in safari –  mheavers Jan 14 '13 at 11:45
i've found something: stackoverflow.com/questions/4622732/… –  algorhythm Jan 14 '13 at 12:08
add comment

1 Answer

up vote 0 down vote accepted


new Date('2012-06-07 13:47:08'); // works

therefore your given parameter must actually have type date. Because the console prints the date. If it's a date then you are trying to do something like that:

var date = new Date();
new Date(date); // doesn't work

And that doesn't work.

To check if your variable is of type date try this:

var isDate = function(date) {
    return Object.prototype.toString.call(date) === "[object Date]";

Ok, found solution: http://jsfiddle.net/nPSqL/2/

Got it from new Date() using Javascript in Safari

share|improve this answer
Nice, thanks. Wondered about those slashes. –  mheavers Jan 14 '13 at 20:56
add comment

Your Answer


