Parsing a date to string

Why I cannot parse a date to this string format ‘2023-08-23T13:00:00Z’? Eventhough… when I create this exact format, it forces the result to print out like this ‘08/23/2023 18:00:00’. I need that specific format for http request and tried different methods to do this without success. It would seem such a simple thing…

ToString(“yyyy-MM-ddTHH:mm:ssZ”)

Hi,

Z which exists at the end of the target format means Universal time.
So if you need to get UT from local time the following expression will help you.

localDateTime.ToUniversalTime.ToString("yyyy-MM-ddTHH:mm:ssZ")

Regards,

1 Like

Hi @ext-o

Try this

Assuming you have a DateTime variable named ‘dateToFormat’
formattedDate = dateToFormat.ToUniversalTime().ToString(“yyyy-MM-ddTHH:mm:ssZ”)

Thank you, this helped. But there is still something that I dont understand… Why does ‘Write line’ gives a different result than ‘Message box’? Write line forces a different type of a string formatting… or maybe this is just a bug.

Hi,

It seems strange… Is this able to be reproduced even if restart Studio?

Regards,

Yes it does give the same result…

Hi,

If possible, can you share the project? It’s no problem to remove other activiites if the issue is reproduced.

Regards,

Hi,

Thank you for sharing.

It seems Studio display bug because these string is written correctly in log file.

Regards,

I figured this out finally. For sure, there is a bug, but now the http request with time parameters is working as ment and I can set the values dynamically

I remove those problematic parameters from the endPoint variable and created a new endPointFormatted in which i assigned this value ‘endPoint + “starttime=” + startdate + “&” + “endtime=” + enddate + “&”’. Now it works.

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