I want to convert this { passagens.departure_date } into date like 1 nov, 2 dez examples. This { passagens.departure_date } is like this value: 2022-10-02T00:00:00Z. I just want to pick the right date in strings. I Try everything. This is my code Also i did the function pegaDia Answer Seems you want something like this… First, create a date formatter
Tag: date-formatting
Convert string to date format in JavaScript
I have a string variable I want the variable into date format. My Code: My Output: Expected Output: Answer You can use toLocaleDateString with an argument that specifies a locale for which your format is used. For instance, the Swedisch locale uses the YYYY-MM-DD format:
How do I get the current date in JavaScript?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. How do I get the current date in JavaScript? Answer Use new Date() to generate a new Date object containing the current date and time. This will give you