Skip to content

date formatting in spfx #4477

@alwaysrcorliss

Description

@alwaysrcorliss

Hi,

Within the first tutorial, you outline how to fetch and display some various columns: text, choices, multiple lines, and booleans. But you don't go over dates.
If I call a date such as Modified date I get:
"2019-08-12T03:19:38Z"

I've made attempts at trying to format this to a simple "MM-dd-YYYY" format but with no luck. I've installed moment.js and tried to format by doing something like:
<div>moment(${item.Modified},"MM-dd-YYYY")</div> in my render method but that doesn't seem to be correct as nothing changes or I literally get the function call as a literal string.

Can someone help point me in the right direction as to how this should be handled in Typescript? I'm just very new to this and would appreciate some direction since your documentation doesn't really cover dates and this seems really important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:answeredAnswer to a question.type:questionQuestion... if answered, will be tagged as such.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions