In javascript I have a Date object with the following value:
Thu Jan 01 1998 00:00:00 GMT+0100 (Central European Standard Time)
Year could be anything, but day and time is always Jan 01 00:00:00
.
Question: How can I set the date to the last second of the chosen year?
In this example: Dec 31 1998 23:59:59 GMT+0100 (Central European Standard Time)
You can instantiate the Date
object with this format:
new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]]);
Details here.
let date = new Date(1998,11,31,23,59,59); //note Month 11 is Dec (0 is Jan)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With