Home > Net >  Today() Function in Google Sheets stuck at Midnight
Today() Function in Google Sheets stuck at Midnight

Time:04-19

Regardless of the time zone I have set on my google sheets doc =TODAY() produces the date but the time stays at midnight 0:00.

I have checked the settings to ensure TODAY() is set to update on change, I have tried formatting the cell as date-time, etc. Nothing seems to work. Any ideas?

CodePudding user response:

what you need is timestamp script:

function onEdit(e) {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) {                       // Sheet name
var r = s.getActiveCell();
if( r.getColumn() == 1 ) { 
  var nextCell = r.offset(0, 1);
  var newDate = Utilities.formatDate(new Date(), 
  "GMT 8", "MM/dd/yyyy hh:mm:ss");                    // Format
  nextCell.setValue(newDate);
}}}

how to deploy a script:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

now you can close the apps script tab/window and enjoy the timestamp script running automatically whenever you type something in A column B column gets timestamped

enter image description here

CodePudding user response:

You need to use the =NOW() function, =TODAY() will just fetch the date. The default time when you transfer a regular date value to a time stamp is midnight.

  • Related