Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I m inserting date and time in database.

It's inserting fine, but time is inserting server time?

How can solve this.



I Have 04/09/2013, 11:13:00 AM
when I Inserting it's 04/09/2013 ,1:13:00 AM (us).

I want to Insert 04/09/2013 ,11:13:00 AM.

C#
//Im passing time like this
CultureInfo CI = new CultureInfo("en-US");
//puch.Time=04/09/2013, 11:13:00 AM 
obj.Scanned_Time = Convert.ToDateTime(Puch.Time.ToString("T", CI));
//in database storing like this 04/09/2013, 1:13:00 AM (us)
//here the date,time is two different fields

here the date,time is two different fields

So how can solve?


Thanks in advance............
Posted
Updated 19-Jun-13 18:57pm
v5
Comments
Pheonyx 19-Jun-13 9:53am    
What code are you using to insert the data?
U@007 19-Jun-13 10:02am    
see updated my code
Richard C Bishop 19-Jun-13 9:58am    
Show the code that is inserting the DateTime into the database.
U@007 19-Jun-13 10:02am    
see updated my code

If you have cloud Access on server just change the Time Format and set the time as your desired format because by default it will take Server Date Time. or


If you don't have cloud access on server, You can Insert it after deducting 120 mins for your desired time.
 
Share this answer
 
Comments
U@007 20-Jun-13 5:05am    
Thank you ravi
:)
 
Share this answer
 
Why are you creating a CultureInfo of type US? I have no idea if this will convert your time or not, but it is not something I would do.

Personally I would just do this:

C#
obj.Scanned_Time = Puch.Time;

without the culture info.
 
Share this answer
 
Comments
U@007 20-Jun-13 0:45am    
Hi Pheonyx,
the date,time two is separate fields.
actually server time is us.that's y we are passing CultureIinfo.
Pheonyx 20-Jun-13 3:06am    
I'm afraid that without seeing more of your code I cannot explain it then. This is not something I've seen occurring before.
Finally I Solved
As I know that, my system time changed to server time. Now working fine.

Thanks for all....... who are given suggestions?
 
Share this answer
 
Comments
Richard C Bishop 26-Jul-13 18:08pm    
You are on the verge of abuse by posting comments as solutions to your own questions and accepting them as answers. Please stop.

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