0

Following is my apex class code.

 public static List<ReportEvent> TransactionalSecurityTmonth()
{
  return[SELECT Name, QueriedEntities, Format, EventSource, NumberOfColumns, Operation, EventIdentifier, PolicyOutcome, Username, format(EventDate) FROM ReportEvent WHERE EventDate = THIS_MONTH];
 }

and Following is my Component code.

Event Date

       <th scope="row">
    <div class="slds-align_absolute-center" style="height:2rem" title="{!perm.PermissionSet.Label}">{!perm.EventDate}</div>
  </th>  

Here i want my format to be displayed in dd-mm-yy year fomat i.e event date although the query output is correct but it is not displayed as it is in my application.

1

Directly referring to date using {!v.EventDate} will show Raw format. You can use lightning:formattedDateTime for appropriately formatting according to your need using its attributes. Below is the example:

<ol class="slds-list_ordered">
    <li>{!v.EventDate}</li>
    <li><lightning:formattedDateTime value="{!v.EventDate}"/></li>
    <li>
        <lightning:formattedDateTime value="{!v.EventDate}"
                                     year="2-digit"
                                     month="2-digit"
                                     day="2-digit"/>
    </li>
</ol>

This will return below respectively:

  1. date - Mon Sep 23 2019 20:46:10 GMT+0530 (India Standard Time) .
  2. 23 Sep, 2019 .
  3. 23/09/19 .
  • Thanks It works fine but i have a problem with my csv file download – psalesforce1989 Sep 24 at 9:25
0

The format of the dates in salesforce (how dates are shown in pages and layouts) depends on the locale configuration of the user.

Here you have a list of the Locales and time formats from salesforce help: https://help.salesforce.com/articleView?id=admin_supported_date_time_format.htm&type=5

If it's vital to have it in dd-mm-yy you will have to do it yourself (play with decomposing the date into day, month and year and then concatenate them).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.