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
Nagarajan CNagarajan C 

Facing issue in Current Date in LWC

Facing issue in Current Date in LWC.

I am auto populated current date in date filed. below is my code in lwc JS.

 connectedCallback() {
             
        //Current Date 
        this.currentDate = new Date().toISOString();
      
    }


but this not working s perfectly Indain stand time . GMT centeral day light time showing one day after. Calender it is showing 24 but autopoulated date is 25.Any one hlep on this issue.

Thanks
C. Nagarajan 
ryanschierholzryanschierholz
Try this:
 
let d = new Date();
        let newD = new Date(d.getTime() + d.getTimezoneOffset()*60000);
this.currentDate = newD.toISOString();

 
Suraj Tripathi 47Suraj Tripathi 47
Hi Nagarajan C,

try this :
connectedCallback() {
             var dateVar = new Date();
        //Current Date 
        this.currentDate = new Date(dateVar.getTime() + dateVar.getTimezoneOffset()*60000).toISOString();
      
    }
---------------
If you find your Solution then mark this as the best answer to close this question. 

Thank you!
Regards,
Suraj Tripathi