new date(); get.month(); question.

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

Through the JSP project, I wrote a code that reads the calendar 3 months ago using new date().get.month();

When you run this code in Eclipse,

It comes out well like this. But if you open it in chrome or edge,

It doesn't print out just 3 months ago. Today, yesterday, a week, a month, and a year are all printed normally, but only three months ago, it is printed well on Eclipse, not on chrome or edge. What's the problem? I'd appreciate it if you let me know.

jsp

2022-09-20 11:38

1 Answers

Please upload the code by attaching it as a text, not as a screenshot.

The code you uploaded is JavaScript, not jsp.

JS cannot parse "2021-9-23" by date, but can parse "2021-09-23". That's the cause.

View demo

Then, if it's less than 10, should I put 0 on it? You may want to, but that's not the case. Think of the date of February 28, 2022 three months ago. This is a more systematic task than you might think, so you need to investigate How others do it.


2022-09-20 11:38

If you have any answers or tips


© 2022 pinfo. All rights reserved.