Get hours from datetime

Get hours from datetime Hello everyone, What is the most straightforward way to get the hours from a datetime variable? For example: I have $DateTime = 2024-06-05 14:00:00 UTC (DateTime type), and I wish to get $hours = 14 (int type). I was thinking something like: $DateTime -> formatTime -> String -> $hours   Is there a function like $Hours = getHours($DateTime) ?
1 answers

Hi Claudio,


Indeed you are thinking in the right direction!


formatDateTime($DateTime, 'HH')  -> Extracts the hour part from the DateTime variable as a string in 24-hour format.


Use the parseInteger function to convert this string to an integer.


Hope this helps!