Luis
10/07/2024, 6:01 AMvar today = new Date();
log.debug('today : ', today);
var yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
log.debug('yesterday : ', yesterday);
var formattedDate = format.format({
value: yesterday,
type: format.Type.DATE,
timezone: format.Timezone.AUSTRALIA_PERTH
});
log.debug('formattedDate : ', formattedDate);
apaule
10/07/2024, 8:44 AMbattk
10/07/2024, 5:18 PMbattk
10/07/2024, 5:19 PMbattk
10/07/2024, 5:20 PMLuis
10/08/2024, 4:43 PMLuis
10/08/2024, 4:48 PMLuis
10/08/2024, 4:53 PMbattk
10/08/2024, 4:55 PMbattk
10/08/2024, 4:56 PMbattk
10/08/2024, 4:56 PMbattk
10/08/2024, 4:59 PMbattk
10/08/2024, 5:00 PMbattk
10/08/2024, 5:01 PMbattk
10/08/2024, 5:04 PMbattk
10/08/2024, 5:06 PMbattk
10/08/2024, 5:10 PMbattk
10/08/2024, 5:27 PMvar yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
which means that the date you are currently working with is 24 hours in the past
const d = new Date(yesterday);
const localTime = d.getTime();
const localOffset = d.getTimezoneOffset() * 60000;
const utc = localTime + localOffset;
you add back the offset, which means that you are adding 7 hours to your (eventual) date, meaning you now have a date which is 17 hours in the past
const offset = 10; // disregard DST
const aus = utc + (3600000 * offset);
const yesterdayInAus = new Date(aus);
finally, you add another 10 hours to your date, meaning you now have a date which is 7 hours in the pastbattk
10/08/2024, 5:35 PM