web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Set Date Field Via Jav...
Power Pages
Answered

Set Date Field Via Javascript

(0) ShareShare
ReportReport
Posted on by 37

Hi,

 

I'm trying to set a date field via java-script; however cannot seem to get the formatting it requires correct.

 

I have tried multiple different date formats e.g. 'dd/MM/yyyy' but cannot find the one it requires.

 

https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings

 

Date.PNG

 

 

$( document ).ready(function() {

// attempt 1
$("#xxx_yearofjoiningthesociety").val("{{ mem.c2memb_fromdate | date_to_iso8601 }}").addClass("readonly");

// attempt 2
$("#xxx_yearofjoiningthesociety").val("{{ mem.c2memb_fromdate | date:'d' }}").addClass("readonly");

// attempt 3
$("#xxx_yearofjoiningthesociety").val("{{ mem.c2memb_fromdate | date:'g' }}").addClass("readonly");

// attempt 4
$("#xxx_yearofjoiningthesociety").val("{{ mem.c2memb_fromdate | date:'dd/MM/yyyy' }}").addClass("readonly");

});

 


@OOlashynmentioned something similar in another thread but could not see the formatting

Thanks,

Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    You are not accessing the date control correctly to set it, and the date control is probably expecting a JavaScript date object, (your Liquid code is just outputting text or a liquid date object).

     

    To default a date you would do something like the following (where you would replace the date text part "2021-01-01" with output from Liquid)

     

    // set a default date
    $("#your_fieldname") // input control
     .next() // the date picker container
     .data("DateTimePicker") // the date picker object
     .defaultDate(new Date("2020-01-01"));

     

     

    (you may still be able to use .val() but it would be expecting a javascript date object)

  • g.whammond Profile Picture
    37 on at

    @FubarYour a star. Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 26 Super User 2026 Season 1

#2
Lucas001 Profile Picture

Lucas001 19 Super User 2026 Season 1

#3
CN-06091549-0 Profile Picture

CN-06091549-0 18

Last 30 days Overall leaderboard