我得到这样的时间
2017-03-06T12:51:33.481Z
desired output time
3/6/2017, 6:21:33 PM
我得到这样的时间
3/6/2017 5:56:33 AM
数据类型是字符串
public string UpdatedTime { get; set; }
码
string updtime = bin.timestamp;//03/06/2017 12:51:33
string ISTTime = Convert.ToDateTime(updtime).ToString("M/d/yyyy, h:mm:ss tt", CultureInfo.InvariantCulture);//3/6/2017, 6:21:33 PM
binModel.UpdatedTime = ISTTime;
答案 0 :(得分:0)
此代码对我有用:
string updtime = "03/06/2017 12:51:33";
string ISTTime = Convert.ToDateTime(updtime).ToString("M/d/yyyy, h:mm:ss tt", CultureInfo.InvariantCulture);//3/6/2017, 6:21:33 PM
var ISTDate = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(ISTTime), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));