-1👍
Dates are never going to be simple, sorry. You’re off to a bad start attacking them with string methods. Moment is deprecated, and you should be able to do without it. This is doesn’t directly fix your problem, but I really recomend you set yourself some rules for date handling. Mine would be: dates should be date objects in your model, formatted at the last moment for display. On the wire, they should be ISO UTC date strings. In the database, they should be UTC datetimes. If you then need to split a datetime into date and time, the date object has all the methods you need: toLocaleTimeString(), toLocaleString(), toLocaleDateString() etc.
Source:stackexchange.com