Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
How to get previous date?

I am trying out a code where I get a mail with specific subject line - "Your daily habit tracker"+previous day's date;

While I figured out how to publish today's date - I am just not able to understand how I can publish yesterday's date instead. Attaching code, please help thank you!

var now = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd-MMMM");

function sendFormEmail() {
    var toEmailAddress = "1@mailinator.com";
    var now = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd-MMMM");
    var htmlMessage = HtmlService.createHtmlOutputFromFile("Habit tracker form.html").getContent();
    var subject = "Daily keystone habit tracker";
    var message = "Some message";
    Logger.log(now);
    // MailApp.sendEmail(toEmailAddress, subject, message, {
    //   name: 'Future Mac',
    //   htmlBody: htmlMessage
    // });
}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let Yesterday = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() -1);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!