I have the following string:
var fecha = "10-ene-2000";
I would like to format it as follows but still be a string:
var result = "2000-01-10 00:00:00"
How can I do it automatically?
I have the following string:
var fecha = "10-ene-2000";
I would like to format it as follows but still be a string:
var result = "2000-01-10 00:00:00"
How can I do it automatically?
To do this you will first have to collect the date in format (YYYY-MM-DDTHH:MM:SSZ). Then convert it to string. Where does date come from? How are you picking it up?
It doesn't help you to format "10-Jan-2000" (string) to "2000-01-10 00:00:00" (string), since a string does not contain the hour/minutes/seconds.
I leave you a link to W3C by the way: Date Formats
Because I understand that you want the hour/minutes/seconds to be correct right?
EDIT: Edit according to comment:
If the issue of not having precision with the hour, minutes and seconds doesn't matter to you (that is, a string with 00:00:00 is generated) I think this solution can work for you.
The first thing is to map the strings of the months as numbers (maybe there is a function that does it, but since I don't know it, I recommend this method that is more flexible).