3

This code was working yesterday but not now. I haven't changed anything... Why is that and how can i fix it?

    {
        var info = TimeZoneInfo.FindSystemTimeZoneById("Turkey Standard Time");
        DateTimeOffset localServerTime = DateTimeOffset.Now;
        DateTimeOffset istanbulTime = TimeZoneInfo.ConvertTime(localServerTime, info);

        con.Open();
        cmd.CommandText = "UPDATE BilgisayarDuyuru SET date='" + istanbulTime + "'  WHERE id='" + id + "'";
        cmd.ExecuteNonQuery();
        con.Close();            
    }
9
  • you'll probably have to clarify your question along with adding a few examples of things you tried in order to receive any help. You can always update your question. Welcome to stack overflow, recommended reading: stackoverflow.com/help/how-to-ask Commented May 13, 2015 at 1:41
  • Did your data change under you? Commented May 13, 2015 at 1:44
  • No i didn't change anything. But now it's working. Still not changed anything. Should i delete this question ? Commented May 13, 2015 at 1:49
  • Not working now means..r u getting any error..please more specific.. Commented May 13, 2015 at 3:09
  • @Sachu Now it's not working again. Not working means it gives the error which in the title :) Commented May 13, 2015 at 3:22

2 Answers 2

4

Ok try this

{
 var info = TimeZoneInfo.FindSystemTimeZoneById("Turkey Standard Time");
 DateTimeOffset localServerTime = DateTimeOffset.Now;
 DateTimeOffset istanbulTime = TimeZoneInfo.ConvertTime(localServerTime, info);
string s1 = istanbulTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff zzz");
con.Open();
cmd.CommandText = "UPDATE BilgisayarDuyuru SET date='" + s1+ "'  WHERE id='" + id + "'";
cmd.ExecuteNonQuery();
  con.Close();            
}
Sign up to request clarification or add additional context in comments.

Comments

0

Yesterday was the 12th today is the 13th. Are you sure that month and day are not being mixed up? After all I'm sure that in Instanbul you only have 12 months?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.