function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chikkuchikku 

Refresh button with time in lwc?

My requirement is when i click the refresh button it should display the date and time like standard report chart.there is any solution 

i need like this
User-added image
This is my code:
Html 
      <button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>
 
js

      
var today = new Date();

console.log("hi");

var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

var dateTime = date+' '+time;

    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

 
Best Answer chosen by chikku
B KarthickeyanB Karthickeyan
@track dateTimeValue;
 expenseAmount(){     
     var today = new Date();

    console.log("hi");

    var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

    var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

    var dateTime = date+' '+time;
    this.dateTimeValue=dateTime

}
    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

If you use @track decorator, you will be able to see the date, Reference the 'dateTimeValue'  in your HTML file as mentioned below.
<button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>view date time</button>
Date time: {dateTimeValue}

All Answers

B KarthickeyanB Karthickeyan
@track dateTimeValue;
 expenseAmount(){     
     var today = new Date();

    console.log("hi");

    var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

    var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

    var dateTime = date+' '+time;
    this.dateTimeValue=dateTime

}
    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

If you use @track decorator, you will be able to see the date, Reference the 'dateTimeValue'  in your HTML file as mentioned below.
<button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>view date time</button>
Date time: {dateTimeValue}
This was selected as the best answer
chikkuchikku
Thank you so much .,it works very well @Karthickeyan
chikkuchikku
It is possible to show the date has ( today) as like in picture ? there is solution
B KarthickeyanB Karthickeyan
can you please elaborate on it? 
Do you want to show it today in the LWC? 
or as shown in the picture, As of yesterday at Time?
if it is time where will you get the data?
chikkuchikku
 yes, I need to show  today instead of showing date(23-07-2020)in numeric. each time I refresh it need to show today instead of the date in numeric in lwc
chikkuchikku
Yes I need to be shown in the picture, As of yesterday or today at Time in lwc