FormatDateTime 12h Format

We are having issues formatting time in 12h format.

FormatDateTime(#2021-02-24 00:01:00#, "hh:mm tt")  = 00:01 AM

Why is it 00:01 AM instead of 12:01 AM?

h: 0-12 without leading zero instead  of 1-12 

hh: 0-12 WITH leading zero instead  of 01-12


Can anyone shed light on this? is this a Platform installation/configuration issue?

mvp_badge
MVP
Solution

Hi Romaniko,


I think you have a very good point, client side format date function doesn't have the same behavior as the server side function and you should report this.

As a workaround, I would not follow the previous suggestions here mentioned for making use of a server side action for several reasons:

  • The advantage of using reactive applications is that you are not dependent from server side actions, you can use client ones which will help you on performance.
  • Using server actions on onInitialize is a bad principle which can be seen on the comment automatically generate by OutSystems when you have onInitialize:



  • Your format action won't work on your mobile app if you are offline since it cannot reach the server if you don't have internet.


Being that said, you can very easily "fix" this behavior with a client action.

I send you an OML with a client-side function you can use to achieve your goal.


Hope it helps.


Kind Regards,
João

ReactiveSandboxTestDateTimeAMPM.oml

Not really the solution but a work around that works.

Thank you.

mvp_badge
MVP

Hi Ramoniko,

I use Format_DateTime (you will find in the references):


AddHours -3, because of my timezone.

it worked for me:

Hope it's help.

Regards.

Hi Ramoinka,

I have tried the same function into both Reactive and Traditional. What I had found that it is working fine in Traditional where as it is displaying 00:01 as is in Reactive. 

Could you please give a try the same function in Traditional app and see the results? If you see difference in result might be we need to open a support case for OS development team.

Thanks & Kind Regards,

Sachin

mvp_badge
MVP
Solution

Hi Romaniko,


I think you have a very good point, client side format date function doesn't have the same behavior as the server side function and you should report this.

As a workaround, I would not follow the previous suggestions here mentioned for making use of a server side action for several reasons:

  • The advantage of using reactive applications is that you are not dependent from server side actions, you can use client ones which will help you on performance.
  • Using server actions on onInitialize is a bad principle which can be seen on the comment automatically generate by OutSystems when you have onInitialize:



  • Your format action won't work on your mobile app if you are offline since it cannot reach the server if you don't have internet.


Being that said, you can very easily "fix" this behavior with a client action.

I send you an OML with a client-side function you can use to achieve your goal.


Hope it helps.


Kind Regards,
João

ReactiveSandboxTestDateTimeAMPM.oml

Not really the solution but a work around that works.

Thank you.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.