Archi Forum

Discussion Boards => jArchi => Topic started by: Alberto on January 29, 2020, 19:21:08 PM

Title: jArchi - parsing dates
Post by: Alberto on January 29, 2020, 19:21:08 PM
What am I doing wrong? This works on the browser, but not on jArchi. Why?

var mydate= Date('2011-04-11');
console.log(mydate)

returns:
Wed Jan 29 2020 13:50:53 GMT-0500 (EST)  <-- current timestamp

Title: Re: jArchi - parsing dates
Post by: Phil Beauvoir on January 29, 2020, 19:26:21 PM
Try:


var mydate = new Date('2011-04-11');
console.log(mydate.toString());


See https://www.w3schools.com/jsref/jsref_obj_date.asp
Title: Re: jArchi - parsing dates
Post by: Alberto on January 29, 2020, 20:34:34 PM
I see now... I was trying to do a simple compare dates and I had a couple of things wrong.  For example, these two scripts output the same, but in one I'm guessing today is undefined, yet it prints the current timestamp ( ??? ?). JS is weird.

var today = Date();
    console.log(today.toString());
var mydate = new Date('2011-04-11');
    console.log(mydate.toString());
console.log(today > mydate);
console.log(today < mydate);



var today = new Date();
    console.log(today.toString());
var mydate = new Date('2011-04-11');
    console.log(mydate.toString());
console.log(today > mydate);
console.log(today < mydate);