jArchi - parsing dates

Started by Alberto, January 29, 2020, 19:21:08 PM

Previous topic - Next topic

Alberto

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


Phil Beauvoir

Try:


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


See https://www.w3schools.com/jsref/jsref_obj_date.asp
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Alberto

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);