Converting Unix timestamp in Google App scripts
NickName:user12297498 Ask DateTime:2019-10-30T21:08:28

Converting Unix timestamp in Google App scripts

I am new to Google App Script and am currently working on a project to help myself get familiar with it. My project has a part where I have to convert Unix Timestamp objects in nested JSON to human-readable time. As I don't know about converting timestamps in Google App scripts, I looked into the documentation and found "Utilities.formatDate()".

I tried using it on an example timestamp to see how it works and if it can be used for my needs. So I took a timestamp from the data and tried converting it with this code.

 function blah () {
  var tim = "1572401067";
  var formattedDate = Utilities.formatDate(tim, "GMT+5:30", "MM-dd-yyyy HH:mm:ss");

  Logger.log(formattedDate);
  }

It ends with an error saying:

Cannot find method formatDate(string,string,string). (line 3, file "Code")Dismiss

What am I doing wrong here?

Copyright Notice:Content Author:「user12297498」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58626103/converting-unix-timestamp-in-google-app-scripts

More about “Converting Unix timestamp in Google App scripts” related questions

Converting Unix timestamp in Google App scripts

I am new to Google App Script and am currently working on a project to help myself get familiar with it. My project has a part where I have to convert Unix Timestamp objects in nested JSON to human-

Show Detail

Converting timestamp to unix epoch time in Oracle SQL

I have a table of 20M records in Oracle with a datetime(one of the columns) column of type VARCHAR and in EST timezone. I am trying to create a new column converting the datetime to Unix epoch time...

Show Detail

Converting SAS datetime to UNIX timestamp in SAS

I'm trying to convert a SAS datetime to a UNIX timestamp but am getting an 8 hour difference in my results. I think it's somehow related to a timezone issue but I can't figure out how. To start w...

Show Detail

Converting UTC timestamp string to UNIX timestamp number - Javascript vs PHP

Do NOT answer this question with the following: "Javascript UNIX timestamps are in milliseconds, PHP UNIX timestamps are in seconds" "Javascript runs in the browser, PHP runs on the

Show Detail

Use default date when converting Unix timestamp

I am converting a unix timestamp to a date thusly TO_TIMESTAMP(CAST( my_column AS BIGINT ) / 1000 ) Attribute named my_column is a TEXT datatype. The developers have designed the source data to ...

Show Detail

How can I turn a UNIX timestamp into a Google Sheets date value?

I'm using Google Apps Script to retrieve some data through an API. The date that is given to me is a standard ISO 8601 string, and I need to convert that to a date number that will be understood by

Show Detail

Pyspark unix_timestamp striping the last zeros while converting from datetime to unix time

I have the following date dataframe, end_dt_time 2020-10-12 04:00:00 2020-10-11 04:00:00 2020-10-10 04:00:00 2020-10-09 04:00:00 2020-10-08 04:00:00 while converting these dates to unix timestamp ...

Show Detail

Converting a 13 digit Unix timestamp to DateTime with Javascript

I'm trying to convert this 13 digit Unix timestamp (1563398686957) to YYYYMMDD format using Javascript. How can I do this? I have divided the 1563398686957/1000 and tried to get the first 10 digit...

Show Detail

Converting a timestamp string to UNIX timestamp in MonetDB

I'd like to convert a timestamp like "2018-02-14 23:59:59" to a UNIX timestamp. I found that the opposite is possible using select sys.epoch(unix_timestamp);. The functions str_to_date, str_to_time...

Show Detail

Converting unix timestamp to a .NET Date Time in javascript

I'm interfacing with an api and they use .NET so all of my time stamps need to conform to .NET's Date Time format which looks something like this /Date(1379142000000-0700)/ I would like to conv...

Show Detail