How to set string to datetime widget?

420 Views Asked by At

The title is self explanatory. I am having difficulties setting a string value to a date time widget.

XCP has a build in function stringToDate

which i use in these examples...

 1. stringToDate('5-5-2009') 
 2. stringToDate('05-05-2009')  
 3. stringToDate('5/5/2009')

But non of them work. What am I missing here ?

Also i set the value of the widget in the behaviors tab of the date widget.

2

There are 2 best solutions below

1
Miki On

If you are talking about Date-Time Input widget then you need to use dateToString not stringToDate.

0
Undisputed007 On

I figured out the issue. It's dependent to the format in which you save your date to string value. If we save the Date-Time Input widget value in this format:

dateToString('12-12-2018', 'm-d-Y')

then doing a :

stringToDate(savedvalue) will work only when the format saved was 'm-d-Y'. It wasn't working before because i saved it as 'd-m-Y'.