0

I want to display created date and time separately in LWC UI. From apex I am returning the created date but not able to get it separately. How can I get date and time separately from created date?

2
  • You can extract these separate components in the LWC JavaScript using standard JavaScript functionality. If, after trying this for yourself, you still have problems, please update this question to show what you've tried and where you are stuck.
    – Phil W
    Commented Jan 18, 2021 at 16:24
  • Thanks for your comment. It worked
    – Raj SF
    Commented Jan 20, 2021 at 7:24

1 Answer 1

0

Typically you just need the set the date value as a date object. Then you can use any date methods you wish to display the day and hours.

Example:

 const createdDateServerValue = “yourValue”;
 const createdDate = new Date(createdDateServerValue);
 const dateValue = createdDate.getDate();
 const hours = createdDate.getHours();
1
  • Thanks for your comment
    – Raj SF
    Commented Jan 19, 2021 at 9:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .