New answers tagged

1

I may assume, that you need DateTime, not Date, because you have hours and minutes specified. Datetime.valueOf() works for format yyyy-MM-dd HH:mm:ss, so you need to replace T with space and remove Z. String toConvert = '2021-06-15T02:30:00.000Z'; toConvert = toConvert.replace('T', ' ').replace('Z', ''); Datetime actualDatetime = Datetime.valueOf(...


1

Here you can convert this using Date static class. System.debug(Date.valueOf('2021-06-15T02:30:00.000Z'));


0

The below code will give you difference between two dates in days. You can divide the final result by 30 then you will get it in months. this.startDate=event.target.value;//get it from onchange this.endDate=event.target.value;//get it from onchange var date1=new Date(this.startDate); var date2=new Date(this.endDate); var dateDiff=(date2.getTime()-date1....


3

.hour() and .date() functions show time in user local time zone already, so you do not need to add offset to now variable. now = Datetime.now(); hourNow = now.hour(); todayDate = now.date();


Top 50 recent answers are included