Try this:
function timeAndDate(){
now = new Date();
var firstDayPrevMonth = new Date(now.getFullYear(), now.getMonth()- 1,1);
var firstUnix = Math.floor(new Date(firstDayPrevMonth).getTime()/1000);
var lastDayPrevMonth = new Date(now.getFullYear(), now.getMonth(),1);
var lastUnix = Math.floor(new Date(lastDayPrevMonth).getTime()/1000);
Logger.log('Starting Date:',firstDayPrevMonth,'- Unix Timestamp format:',firstUnix);
Logger.log('Ending Date:',lastDayPrevMonth,'- Unix Timestamp format:',lastUnix);
var body = Logger.getLog();
var recipient = Session.getActiveUser().getEmail();
MailApp.sendEmail(recipient,'App script logs',body);
}
Using getLog()
when Logging executions using the Logger class
allows you to track the execution and with a simple code you can then email it to yourself using the MailApp.sendEmail
method.