我在日期明智的过滤器中从5.30 am获取记录,在时区发布

时间:2018-08-31 12:24:57

标签: c# datetime

我想获取具有日期报告的记录,但是我要从所选日期的5.30am获取记录。时间种类-utc

json响应

{"timestamp":"2018-08-24T12:36:13.519Z","dataFrame":"AQAPAyoADwMqAA8BKiM="}

模型

public DateTime timestamp { get; set; }

代码

List<FeederPillar> Pirs = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FeederPillar>>(responseString);
    Pirs = Pirs.Where(x.timestamp.Date >= fromDate.Date && x.timestamp.Date <= toDate.Date).ToList();
    foreach (var item in Pirs)
    {

        dataframe = item.dataFrame;
        byte[] data = Convert.FromBase64String(item.dataFrame.ToString());
        FeederPillar FeederModel = new FeederPillar();
        string updtime = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(item.timestamp), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")).ToString();
        FeederModel.datetime = Convert.ToDateTime(updtime).ToString(string.Format("dd/MM/yyyy hh:mm:ss tt"));

    }

1 个答案:

答案 0 :(得分:0)

Pirs = Pirs.Where(TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(x.timestamp), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")).Date >= fromDate.Date && TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(x.timestamp), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")).Date <= toDate.Date)
                        .ToList();