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 Apps / PCF CLI date formattin...
Power Apps
Answered

PCF CLI date formatting bugs

(0) ShareShare
ReportReport
Posted on by 21

I have a requirement to format the date values shown in my PCF control (a dataset) in the UK format. Ideally, I would use the users specified display format for dates, and looking through the API documentation I found these two options, but of which should work:

 

context.formatting.formatutcdatetimetouserdate 

and

context.formatting.formatdateshort 

 

Unfortunately, neither of these options seem to work correctly.

 

When building the control, Visual Studio Code says that formatUTCDateTimeToUserDate doesn't exist, however when debugging the control in the browser I can inspect the context and see that this method is there. I have tried updating the CLI in Visual Studio Code (using pac install latest), and it seems the latest version of the CLI is installed.

 

When using formatdateshort if I specify the includeTime parameter as true, I get the following error at run time:

 

Uncaught (in promise) TypeError: e.getTime is not a function
 at w (/uclient/scripts/app.js?v=1.4.3587-2111.3:2085)
 at Function.ae [as formatShortDateTimeValue] (/uclient/scripts/app.js?v=1.4.3587-2111.3:2730)
 at e.formatDateShort (/uclient/scripts/8.js?v=1.4.3587-2111.3:4)
 at eval (webpack://pcf_tools_652ac3f36e1e4bca82eb3c1dc44e6fad/./CustomLookup/index.ts?:490)
 at /uclient/scripts/app.js?v=1.4.3587-2111.3:709
 at i (/uclient/scripts/app.js?v=1.4.3587-2111.3:308)
 at a (/uclient/scripts/app.js?v=1.4.3587-2111.3:709)

 

 

Have I missed something or are these not working currently?

I have the same question (0)
  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Polmon , 

     

    There is an easier way to get the formatted values for the records inside a dataset PCF.

    You don't need to call the formatting methods. You have the formatted values right inside the dataset record: 

     https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/entityrecord/getformattedvalue?WT.mc_id=BA-MVP-5004107

     

     

    dataset.records[id].getFormattedValue(columnName) 

     

     

    Hope this helps!

  • skoofy5 Profile Picture
    482 on at

    Hey mate - I use 'formatDateShort' without issue, but don't usually ask for the time to be returned like so:

    const formattedDate = context.formatting.formatDateShort(unformattedDate, false)


    So I ran a quick test for you to see if I had any issues, but didn't encounter any problems. The time got returned as well:

    skoofy5_1-1639731307985.png
    You're definitely passing a Date object?

    skoofy5_2-1639731602591.png

  • Polmon Profile Picture
    21 on at

    Sorry, I should have specified that I was looking to format the result from a context.webApi.retrieveMultiple for a datetime column. @DianaBirkelbach was on the money there; I hadn't looked at the resulting dataset to see that the formatted value was already included by accessing the "columnName@OData.Community.Display.V1.FormattedValue" property.

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard