dimanche 31 juillet 2016

Firebase Date storage goes wrong

So I am trying to store a date in Firebase like this:

 var fb = new Firebase(FIREBASE_URL);
        var syncData = $firebase(fb);
        var date = new Date(2014, 0, 1);
        console.log(date);
        syncData.$child('date').$set(date);
        var dateInFirebase = syncData.$child('date');
        dateInFirebase.$on('loaded', function(){
            console.log(dateInFirebase.$value);
        });

The first date correctly logs 'Wed Jan 01 2014 00:00:00 GMT+0100 (CET)', however the second log is this: '2013-12-31T23:00:00.000Z' which is 1 day before that, is this some bug in firebase or am I missing something obvious? I haven't found any other questions on this so I'm inclined to think I did something wrong, I just don't know what.

EDIT: Okay now I'm totally confused, if I replace the dateconstructor with the empty constructor (today's date) he stores the date correctly..

Aucun commentaire:

Enregistrer un commentaire