Hoppa till huvudinnehållet

DatePicker set current date; get date

Kommentarer

9 kommentarer

  • Stefan Schweigert

    Hello Will,

     

    1: Currently there is no easy method for setting the current date. There's an existing feature request for this, which I've added your name as a stakeholder.

    2: For the Date Picker, there's actually another level within the DatePicker value. If you want the basic display text, use $form1.state.DatePicker1.value.display and if you intend to do more complex date formatting, use the $form1.state.DatePicker1.value.value (UNIX time) as an input to the Format Date, where you can then define exactly how you want to date to be displayed.

     

    Thanks, Stefan

    0
  • Permanently deleted user

    Found a workaround for setting the current date:

    1. Add a Run Arcade Script action
    2. Set the script to:
    Now()+""

    3. In the DatePicker Load event use Set Property to the Arcade script result (all settings for clarity):

    • Object:
    =$form1.state.DatePicker1
    • Property Name: value
    • Property Value:
    =$arcadescript1.result+""

     

    Will

    0
  • Stefan Schweigert

    That's a good method to set it, thanks for the logic.

    0
  • Permanently deleted user

    Stefan: Please add my name to the feature request to set the DatePicker to the current date.

     

    Thanks,

     

    Chris

    0
  • Andrew Flynn

    I know I'm late to the party here, but I'll share what I've found.

     

    If you open the date picker on load event you can use the "set form element property" and set the "value" property to "=Date.now()".

     

    This seems to be a very quick and easy method to get the date automatically set in your forms.

    1
  • Stefan Schweigert

    The functionality that Andrew mentioned was introduced in the recent 5.5 release. You can use this value as an input to a Format Date to display a formatted date.

    0
  • Jostein Svegården

    Actually, I don't think this is working as it should. I use two datepickers to set from date and to date in a search for available images in a time enabled image service. At form.load i set their VALUE properties of fromdate =Date.now()-2592000000 and todate = Date.now() with Set Form Element Property to get the timespan for the last 30 days. Apparently, this works, i.e. the two dates look correct in the form. But under the hood, something seems wrong. 

     

    When I use Format Date with =$form1.state.datePicker.value.value as input, today's date is always returned for both dates. When I look at the FormatDate object in the console, it states that the input date was undefined. So it seems like Set Form Element Property to set the value of a date picker sets the date visually correct in the form, but that its value.value is undefined

     

    Interestingly, when logging =$form1.state.datePicker.value to the console after Set Form Element Property, the epoch time number is logged, not a dateTimeRef object that has a value property as you would expect

    0
  • Permanently deleted user

    Hello,

     

    I know it's an older post, but maybe someone here has an idea. I figured out how to set current date or custom date as default, but I would like to set default time as well. And I cannot figure out how to do that? For my start time I you like it to be 12:00:01am and for my end time I would like it to be 11:59:59pm.

     

    time_setting 

    Thank you,

    Nataliya

    0
  • Jostein Svegården

    Guess you could use the Date.parse() function to get the unix time you want, and use Set Form Element Property to set that as the date picker's value

    0

Du måste logga in om du vill lämna en kommentar.