LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Saturday, August 1, 2020

日時をUNIX TIMEに変換したい


MISSION
日時をUNIX TIMEに変換する


KEY 
UNIX TIMEは「秒」なので1000で割って「ミリ秒」にしてから扱う
toString()は()に基数を指定しない場合は10進数を返す

const sec = milsec / 1000;
const unixtime = sec.toString();


ということで関数をひとつ書きました。



コード.gs
function getUnixTime() {
  const date = new Date();
  const milsec = date.getTime();
  const sec = milsec / 1000;
  const unixtime = sec.toString();
  Logger.log(unixtime);
}


Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...