Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  114] [ 5]  / answers: 1 / hits: 17101  / 11 Years ago, fri, june 7, 2013, 12:00:00

I have Date in this format mm/dd/yy example: 04/11/13
and time in the format HH:MM:SS example: 17:02:30



I have to parse above two values and put in a variable dateTime with following format



YYYY-MM-DDTHH:MM:SSS

2013-04-11T17:02:30.000


What is best way to do it in AngularJS or in Javascript. I also need to verify the user input and make sure it is a valid mm/dd/yy date and a valid HH:MM:SS time



I know there are tons of duplicate/similar questions but I couldn't find one which answers above, please let me know if you found one.


More From » jquery

 Answers
80

You don't need an external library to do this. See this doc link for the forms of date that JavaScript can process normally.



For a specific solution to your question:



var date = new Date(04/11/13 +   + 17:02:30);
date.toISOString();
>> 2013-04-11T21:02:30.000Z


See this MDN page for more info on the Date object.


[#77749] Thursday, June 6, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
wilson

Total Points: 27
Total Questions: 93
Total Answers: 93

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
wilson questions
Tue, Aug 9, 22, 00:00, 2 Years ago
Wed, May 11, 22, 00:00, 2 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
Wed, May 13, 20, 00:00, 4 Years ago
;