Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can some one help me with this ?
How to Convert a string that is in (M: d:yy hh:mm:ss tt) format to (MM/dd/yy hh:mm:ss tt) format in javascript without using moment.js

What I have tried:

tried using many alternatives .. but couldn't get any results.. can someone help me soon ?
Posted
Updated 2-Sep-16 18:34pm
v4

Check this jsfiddle:

convert date time - JSFiddle[^]
 
Share this answer
 
Comments
Maciej Los 2-Sep-16 10:39am    
5ed!
The first line is the date in string format.
The second line is an instance (a variable) of date object. The string to date format conversion is done here. Naturally, you'd do conversion with the parse method, but this approach is better and cleaner.
The third line displays the date format in a pop-up box.

I hope this helps.
 
Share this answer
 
Hi,

I've tried out this code and I hope you'd understand.
If you store the datetime value into a string str and pass it as argument to the Date object like below:

JavaScript
var str = "09/02/2016 14:00:00";
var todate = new Date(str);
window.alert(todate);


You can do whatever you wish to the value returned, in this case "todate".

Regards

hubsnippet
Daystarter
 
Share this answer
 
Comments
njammy 2-Sep-16 10:58am    
Where is the date format conversion code...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900