0

I am using

var TIMESTAMP_FORMAT = "yyyy-MM-dd hh:mm:ss a";
var TZ = "GMT-7";

in my script code of Google document

I want it to be convert into 24 hrs timestamp

What changes should I do ?

0
  1. Replace hh by HH
  2. Remove a

Example

function myFunction() {
  var TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss";
  var date = Utilities.formatDate(new Date(2020,5,5,18,23,3), Session.getScriptTimeZone(), TIMESTAMP_FORMAT);
  Logger.log(date)
};

Reference

2
  • getting result 12 hr i need 24 hrs Apr 11 '20 at 19:41
  • @PareshParesh I edited my answer.
    – Rubén
    Apr 11 '20 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.