0

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.

Undisputed007
  • 639
  • 1
  • 10
  • 31

2 Answers2

0

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

Miki
  • 2,493
  • 2
  • 27
  • 39
  • Date-Time Input requires object type `Date` as parameter. I will use dateToString if i want to store the Date-Time Input as string somewhere. But that is what i already did, and now i want to return that stored string in the widget for display. Which will intuitively mean i need to use stringToDate. But the case is,it accepts the input but nothing is displayed. – Undisputed007 Jan 19 '17 at 07:29
0

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'.

Undisputed007
  • 639
  • 1
  • 10
  • 31