📅  最后修改于: 2022-03-11 14:55:31.738000             🧑  作者: Mango
Datetime startDate = system.now();// Start date
Datetime endDate = system.now().addHours(60);//End Date
Integer noOfDays = startDate.Date().daysBetween(endDate.Date());
System.debug('No Of Days : '+noOfDays);
Datetime sameDayEndDate = startDate.addDays(noOfDays);
System.debug('Same Day : '+sameDayEndDate);
Decimal decHours = ((endDate.getTime())/1000/60/60) - ((sameDayEndDate.getTime())/1000/60/60);
System.debug('Dec Hours : '+decHours);
decimal decMinutes = ((endDate.getTime())/1000/60) - ((sameDayEndDate.getTime())/1000/60);
System.debug('Minutes : '+decMinutes);