Get hours from datetime

0
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) ?
asked
1 answers
2

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!

answered