Displaying and saving time in 12 hour AM/PM format
When Power Apps sets up a Date/Time field, the hours are in 24 hour format. Have you ever wanted to work with a 12 hour AM/PM choice and display for the user ? Here is how
Add another drop-down at the right with Items
["AM", "PM"]
and the Default of this drop-down
If(
Hour(Parent.Default) < 12,
"AM",
"PM"
)
Then you need to change the Items of the Hour drop-down to
["12","01","02","03","04","05","06","07","08","09","10","11"]
and the Default of the Hour drop-down
With(
{
_Hour:
Mod(
Hour(Parent.Default),
12
)
},
Text(
If(
_Hour = 0,
12,
_Hour
),
"00"
)
)
Now the Update of the Data Card for the Hour dropdown
DatePickerName.SelectedDate +
Time(
If(
AmPmDropdown.Selected.Value = "PM",
12,
0
) +
Mod(
Value(
HourDropdown.Selected.Value
),
12
),
Value(
MinuteDropdown.Selected.Value
),
0
)
This all should now allow you to perform this function
2 Comments
Nat
Hi Warren,
Hope you are doing great.
I hope I can learn more from you.
Harper Bush
This was so clear and helpful! Thanks for posting!