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:
  • Verified answer
    Fubar Profile Picture
    17 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 18 Super User 2026 Season 2

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#3
CU08101843-0 Profile Picture

CU08101843-0 4

Last 30 days Overall leaderboard