-1

I converted the date time using TimeZoneInfo in mvc2.

In my controller:

DateTime updatedDate = DateTime.Now;
var timeZone = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(updatedDate, TimeZoneInfo.Local.Id, "India Standard Time").ToString();

I want to assign the value timeZone into

item.updateddate=timeZone;

But it is showing an error. How to assing the values? I am new to this....

PoliDev
  • 1,408
  • 9
  • 24
  • 45

1 Answers1

0

As I assumed your error is because you are trying to convert a string to a date time. What you need to do is use something like DateTime.ParseExact.

Example here

Damon
  • 3,004
  • 7
  • 24
  • 28
  • Thanks for your answer.. I find the issue because of you. var timeZone = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(updatedDate, TimeZoneInfo.Local.Id, "India Standard Time"); – PoliDev Sep 14 '13 at 09:16
  • Ahh, you were converting the return value to a string. That would have caused your problem! – Damon Sep 14 '13 at 09:19