7

I'm trying to insert the current time as a static value in Google sheets on a mobile device.

The keyboard shortcut Ctrl + Shift + ; works on the desktop but not the mobile app and "=NOW()" works to insert the time but as a dynamic value.

Is there a script I can use to cut and paste the dynamic value as a static value?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
user3776107
  • 71
  • 1
  • 3

2 Answers2

4

On a mobile app, none of the script-based UI extensions will be visible, but if you're willing to use the full web interface on your device (ouch), you could add a menu or sidebar add-on that inserts the current time into the active cell.

Here's a hack that watches for specific text being added to a cell, then updates the content with the current date. (You can format the cell to display time instead.) Just put #datetime in any cell, and watch it be replaced. Note though, that this only works for EDITs, not other types of changes. Tested with Sheets app on iOS7.2, and it works.

/**
 * onEdit trigger function is called whenever text is edited in
 * the spreadsheet.
 *
 * If the content criteria is met, content will be replaced with
 * current time.
 */
function onEdit(e) {
  if (e.value.toUpperCase() == '#DATETIME') {
    e.range.setValue(new Date());
  }
}
Community
  • 1
  • 1
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
-2

As of today, Google Sheets App has an icon for inserting static DateTime.

You have to select the entire column or cell format as Date Time from the Format menu first.

Format > Number > Date time

enter image description here

umar14
  • 31
  • 8
  • This is great, but it doesn't insert the current date and time, I have to select it. This is a couple of taps because it defaults to the current date and time, but the time is not accurate to the second (it doesn't even insert a second!) and tapping delays a second or two as well. – Michael Dec 06 '20 at 18:59
  • I do not see the calendar icon in the iOS version of the app – Michael Apr 16 '21 at 05:25