Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am Trying to Insert the local Time in Server.But failed to insert

as i want local Time as yyyy-mm-dd HH:mm:ss(24hrs) format.but I am conversion errors

can Anybody Help me..

Thanks in Advance..
Posted
Comments
Nirav Prabtani 9-Jul-13 7:58am    
can you show your code here??
[no name] 9-Jul-13 7:58am    
I am using toLacaleString method for formating but it is showing like this m/d/yyyy 5:12:00 PM but i want to string as yyyy-mm-dd HH:mm:ss(24hrs) so i can store in sql server data base
[no name] 9-Jul-13 8:24am    
how to get a format yyyy-mm-dd HH:MM:SS(24Hrs) in javascript

Usually to change date format on SQL server side SET DATEFORMAT[^] command is used.

SQL
SET DATETIMEFORMAT ymd;

INSERT INTO ...


But if you want to get local time on client machine using JavaScript, see this:
http://stackoverflow.com/questions/6838197/get-local-date-string-and-time-string[^]
 
Share this answer
 
v2
Comments
[no name] 9-Jul-13 8:04am    
how to get local time in c# and covert to a format required.
Maciej Los 9-Jul-13 8:13am    
You're asking about: I am Trying to Insert the local Time in Server.But failed to insert...
So, my answer is like you see.

http://stackoverflow.com/questions/9888420/asp-net-how-to-get-user-local-time-at-page-load[^]
[no name] 9-Jul-13 8:24am    
how to get a format yyyy-mm-dd HH:MM:SS(24Hrs) in javascript
Amol_B 9-Jul-13 8:35am    
That should solve problem for sure
 
Share this answer
 
Comments
wots up frnds 9-Jul-13 8:08am    
i think its not help full for him anyway nice work
[no name] 9-Jul-13 8:24am    
how to get a format yyyy-mm-dd HH:MM:SS(24Hrs) in javascript
Manuel john 10-Jul-13 3:09am    
see this
http://tylerfrankenstein.com/user/4/code/javascript-date-time-yyyy-mm-dd-hh-mm-ss
 
Share this answer
 
v3
Comments
[no name] 9-Jul-13 8:04am    
i want to store local time not server time
Thanks7872 9-Jul-13 8:10am    
Refer to updated answer.
[no name] 9-Jul-13 8:24am    
how to get a format yyyy-mm-dd HH:MM:SS(24Hrs) in javascript
Thanks7872 9-Jul-13 8:26am    
Refer to updated answer(3rd link)
Check this:

SQL Server Date Formats[^]

hope it helps :)
 
Share this answer
 
Comments
[no name] 9-Jul-13 8:05am    
i need to store local time using Date object in js and store it into in server
[no name] 9-Jul-13 8:24am    
how to get a format yyyy-mm-dd HH:MM:SS(24Hrs) in javascript
Check the database date column format.
 
Share this answer
 
Comments
[no name] 9-Jul-13 8:25am    
how to get a format yyyy-mm-dd HH:MM:SS(24Hrs) in javascript

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