Legacy Dev Forum Posts

 View Only

Sign Up

Parse response from Platform date utility api to get HH

  • 1.  Parse response from Platform date utility api to get HH

    Posted 06-05-2025 18:41

    dmthames | 2018-10-16 20:42:57 UTC | #1

    Hello,

    Trying to use the "/api/v2/date" api so that I can get a time value into a call flow and make a routing decision based on the value (would like to use multiple different call flows intra-day).

    The response is shown below, but all I need is the HH value after the T. Any way to parse that out easily?

    [ { "currentDate": "2018-10-16T20:34:19.241Z" } ]


    tim.smith | 2018-10-16 21:04:01 UTC | #2

    It would be a lot easier to use the architect variable Flow.StartDateTimeUTC or the expression function GetCurrentDateTimeUtc() and then use the function hour() to get the hour from the datetime variable.


    dmthames | 2018-10-17 12:01:52 UTC | #3

    Thanks Tim... Makes sense. I'll give that a shot.


    anon28066628 | 2018-10-18 13:41:55 UTC | #4

    The response from your data action can also be converted to a DateTime object with the function below, and then used with hour(). "ToObject" functions exist for many standard string formats, helping with parsing. Tim's suggestion to use Flow.StartDateTimeUTC avoids a REST call and round-trip to cloud, though, so if it fits your purpose, it's the better method. Be aware StartDateTimeUTC does not update as the flow executes - it's the static start time of the flow.

    DateTime ToDateTime(String text) Converts a String value to a DateTime type.

    Return Value

    • DateTime : Returns a DateTime from a supplied string. Note: The returned DateTime value will be in Coordinated Universal Time.

    Parameter

    • String text : The String value to convert to a DateTime. The String must be in the following format: YYYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm] where YYYY = 4 digit year, MM = 2 digit month, DD = 2 digit day, hh = 2 digit hour, mm = 2 digit minute and ss = 2 digit second. T is a separator indicating where the time portion starts. [Z|(+|-)hh:mm] represents the offset of the date time from Coordinated Universal Time where Z indicates Coordinated Universal Time (UTC) itself. If "[+|-]hh:mm" is used instead of Z that specifies an offset from UTC.

    system | 2018-11-18 13:41:57 UTC | #5

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


    This post was migrated from the old Developer Forum.

    ref: 3750