Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Friends..
.. getting local time using javascrit..Here Problem is i am getting the time but in var variable ..I am unable to send to database..Can any one help me how to convert var variable to datetime format..?
Posted
Comments
F-ES Sitecore 14-Oct-15 4:54am    
JavaScript var? or .net var? JavaScript datetime or .net datetime? You are using very confusing language, you talk about js but your tags are about .net, we have no idea when you are talking about client-side and when server-side.
12045649 14-Oct-15 5:25am    
Sorry ...Acutally i am using javascript ..in asp.net source code..Now i want to convert var variable to datetime format because i need to send to database..
Philippe Mori 14-Oct-15 13:02pm    
Show relevant code...

1 solution

You can Use Date() function of javascript.
C#
var dt = '10/14/2015';
        var a = new Date(dt);
        alert(a);

you can get the date culture specific
C#
var dt = '10/14/2015';
        var a = new Date(dt).toLocaleDateString("en-US");
        alert(a);

this will give date format in en-US culture.
Format Date in Javascript[^]

you can refer the link for detail how you can use date format in javascript
Javascript Date
Valid Javascript Date Format[^]
 
Share this answer
 
v3
Comments
12045649 14-Oct-15 5:29am    
kk i tried this code now.. how Can u send to database sql server which is in datetime format string
[no name] 14-Oct-15 5:58am    
Please see the updated solution ..

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