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
2 answers
3

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
0

Mendix people, who are you, which background do you have? 

You ask developers do format datetime to string and then parse string to int to get Hours, year, etc.  Are you serious?

answered