locked
Want to display date and time based on timezone id Nodatime C# RRS feed

  • Question

  • User88744855 posted

    i heard that if i use nodatime library then i can get date & time based on timezone id. first i change my pc date and time. set to old date and time in my pc and then run the below code which disappoint me.

    using NodaTime;
    
        var zoneId = "Asia/Kolkata";
        DateTimeZone _zone = DateTimeZoneProviders.Tzdb[zoneId];
        ZonedDateTime _now = SystemClock.Instance.Now.InZone(_zone);
        var xx = _now.LocalDateTime;

    below code display wrong date & time because i set my pc date & time to few days back.

    is there any way that if date & time is wrong but still code display right date & time without depending on user pc date & time setting using Noda Time library. looking for suggestion. thanks

    Thursday, December 4, 2014 2:31 PM

Answers