David Heimowitz
David Heimowitz

Reputation: 1

How to store month, day, and year in a variable in Google Scripts?

How would I store "yy," "dd," and "MM," in a var?

var date = Utilities.formatDate(unformattedDate, "EST", "MM/dd/yy");

Upvotes: 0

Views: 120

Answers (1)

Diego
Diego

Reputation: 9581

I'm assuming that you want the formatted values of "yy", "dd", and "MM", so you should look at using split().

var date = Utilities.formatDate(unformattedDate, "EST", "MM/dd/yy");
var dateParts = date.split("/"); // [MM, dd, yy]
var month = dateParts[0];
var day = dateParts[1];
var year = dateParts[2];

Upvotes: 1

Related Questions