Add hours and minutes into Date.UtcNow

Hi All,

I want to add hours and minutes into Date.UtcNow from below input

  1. UTC +01:00
  2. UTC +01:30
  3. UTC -01:00
  4. UTC -03:30

Thanks in advance!! :grinning:

Check this below link, @Arpit_Kesharwani


Hope this may help you :slight_smile:
1 Like

@Manish540 Thank you for your help, but I just want to extract hours and minutes info from the input to get it done in a minimal line of code.

So you want to extract only “01:00” from “UTC +01:00” right?

@Manish540 I am able to extract 01:00 but also want + or - and then get hours and minutes info to add into utc

Use this below regex expression to extract the value from input, @Arpit_Kesharwani
“[+|-]+\d{2}:\d{2}”
Check the link,

@Manish540 How I can pass these extracted value(e.g. +01:00) to get the added date?

I am able to resolve the issue by myself. Thanks @Manish540


Solution References : https://stackoverflow.com/questions/33118971/sign-in-timespans-parseexact
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.