I get JSON date and time values from an API call.
I need to format the date and times for display. Would this code do what I am trying to do?
I get JSON date and time values from an API call.
I need to format the date and times for display. Would this code do what I am trying to do?
Hello Ryan,
A couple of things. To format a date we must create a date variable first, so the way is the below one:
The other thing is related with the "ObjectGetProp" action. It's no problem to use it, but, for your knowledge, it's also possible to directly access the object properties from the server's response, so, it's possible to write something like the below one:
I followed the pattern you pointed out here:
All I get in the Alert is "Invalid Date". If I declare NewDate with a value and format, why do I need to call DateFormat?
Can the date formats be MM/DD/YYYY?
Hello Ryan,
With "NewDate" you create a new date variable, and, since you do it using a value, you specify the format of that value, in order to properly create the date. Once you have a date variable, and, if you want to show it, then you can use the "DateFormat" action.
I think the problem here can be the time format, that is, probably we can't create a date variable only with time information / format. So, if we can't create the date variable correctly, we can't format that non valid date variable.
Are there any suggestions of how to handle this issue? Maybe JS would handle it better? Could I format the time values as a date and time like MM/DD/YYYY HH:MM A and then use DateGet to build a string representing the time?
Hello Ryan,
I think we are missing something here, because, in fact there is no issues, that is, take a look at the below code:
This time we take in consideration both date and time, so, what "[FormattedDate]" stores is "2019-09-15 21:22:23". In other words, it's perfectly possible to create a date variable which include the date and the time.
Maybe I confuse you because I mention above that we can't create a date variable only with the time... and this is truth, that is, only with the time we can't create a date variable, but, we can create date variables (as you can see below) that stores both date and times values.
Once we have a date variable, we can use several available actions to extract the days, month, etc. Or just to show the date variable in certain format, like the code above does.
Hello Ryan,
It's another way, of course, but, please, don't use the server... if you want to use the client... as you can see above, it's possible to create a date variable from an arbitrary value, and, then it's also possible to show that date variable in certain specific format. It's possible, so, if you find any trouble... just post it here and we will see...
Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.
Este sitio utiliza "cookies" útiles para almacenar sus preferencias.