+ Start a Discussion
venkat bojjavenkat bojja 

How to Display the current system date with Time in lightning

Hi Team,

How to Display the current system date and Time with better UI template in lightning.Please help me on this.
                                 Thanks in advance....
Thanks
bvr.
SandhyaSandhya (Salesforce Developers) 
Hi,

Refer below sample code.
 
<aura:component>
   <aura:handler name="init" action="{!c.init}" value="{!this}" />
   <aura:attribute name="today" type="Date" />
</aura:component>
 
init : function(component, event, helper) {
    var today = new Date();
    var monthDigit = today.getMonth() + 1;
    if (monthDigit <= 9) {
        monthDigit = '0' + monthDigit;
    }
    component.set('v.today', today.getFullYear() + "-" + monthDigit + "-" + today.getDate());
}

https://salesforce.stackexchange.com/questions/164230/how-can-i-quickly-get-todays-date-in-a-lightning-component-for-use-in-an-attr

https://salesforce.stackexchange.com/questions/175573/how-to-get-current-date-as-per-logged-in-user-in-lightning-component/175677
 
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,
​Sandhya
 
venkat bojjavenkat bojja
Hi  Sandhya,

Thanks for your quick responce. I tried with your code but i am not getting any output. Could you please check it once.And i need to get the output like below format in image.Please help me on this.
                                                                  Thanks in advance...

User-added image\

Thanks
bvr.