Parse datatime ignition perpective

Hello Someone can explain to me why I'am having a error whith the fucntion system.date.parse:

 my  self.view.params.datetime = 03nov.2022 09:53:52 AM
date = system.date.parse(self.view.params.datetime,'ddMMMyyyy hh:mm:ss a')

On my log I found this error:
Error running action 'dom.onClick' on Building Automation Demo/Page/Systems Overview/Framework/Dashboard/Widgets/Activity ```
Log/Row@C$0:0:0$0:1$0:1$0:0[dashboard-widget-10]$0:0$0:3[0]/root/Body/User And More/More And Edit Cont/More: Traceback (most recent call last): File "<function:runAction>", line 14, in runAction at ```

java.base/java.text.DateFormat.parse(Unknown Source) at com.inductiveautomation.ignition.common.script.builtin.DateUtilities.parse(DateUtilities.java:445) at jdk.internal.reflect.GeneratedMethodAccessor476.invoke(Unknown Source)
``` at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown ```
Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) ```
java.text.ParseException: java.text.ParseException: Unparseable date: "03nov.2022 09:53:52 AM"

Hi,

I think you need to do it like this:

dateStr = "03nov.2022 09:53:52 AM"

date = system.date.parse(dateStr, "ddMMMM.yyyy hh:mm:ss a")
print date
#Output: Thu Nov 03 09:53:52 CET 2022

1 Like

Hi, I didn't understand what you wanted me to do

03 nov.2022 09:53:52 AM is a value that get on my param.
I put script on a button. when I click it, I'm got the error that I have posted



Change

date = system.date.parse(self.view.params.datetime,'ddMMMyyyy hh:mm:ss a')

to

date = system.date.parse(self.view.params.datetime,'ddMMMM.yyyy hh:mm:ss a')
1 Like

thank you, it work now