Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using NodaTime;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Get now from system clock (this is an Instant)
- var now = SystemClock.Instance.Now;
- //get zoned datetime of now
- var ztNow = new ZonedDateTime(now, DateTimeZone.Utc);
- //now minus 8 months period converted to local datetime
- var ltBeforePeriod = ztNow.LocalDateTime.Minus(Period.FromMonths(8));
- //Get zoned date time in utc
- var ztBeforePeriod = ltBeforePeriod.InUtc();
- //or convert it to your zone
- //ltAfterPeriod.InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("your zone id"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement