Compare date

I have a date format like this “January 6, 2023, 11:42 am”
I want to convert it to unix time and then compare with current date

BLOCK:DateToUnixTime
  datetime = "January 6, 2023, 11:42 am"
  format = "MMMM dd, yyyy, hh:mm tt"
  => VAR @unix
ENDBLOCK

this gives me a problem as the days sometimes are with one number “1-9” and other times with two numbers “10-31”
How can I solve this?

format = “MMMM d, yyyy, hh:mm tt”
format = “MMMM dd, yyyy, hh:mm tt”

Solved it:

BLOCK:Parse
LABEL:Parse expire date
  input = @data.SOURCE
  leftDelim = "\"phone\":\""
  rightDelim = "\"}"
  MODE:LR
  => VAR @expire
ENDBLOCK

// Parse the date string into a DateTime object
DateTime dt = DateTime.Parse(expire);
string formattedExpireDate = dt.ToString("dd-MM-yyyy");
BLOCK:DateToUnixTime
  datetime = $"<formattedExpireDate>"
  format = "dd-MM-yyyy"
  => VAR @expireUnixTimeOutput
ENDBLOCK

BLOCK:CurrentUnixTime
  => VAR @currentUnixTimeOutput
ENDBLOCK

BLOCK:Keycheck
  banIfNoMatch = False
  KEYCHAIN FAIL OR
    INTKEY @expireUnixTimeOutput LessThan @currentUnixTimeOutput
  KEYCHAIN SUCCESS OR
    INTKEY @expireUnixTimeOutput GreaterThan @currentUnixTimeOutput
ENDBLOCK
1 Like