A
A
aminodovborisov2021-01-21 12:54:36
Google Apps Script
aminodovborisov, 2021-01-21 12:54:36

How to get date format from date string and time string?

Hello.
I have a google sheet. It has a date column ("dd.MM.yyyy") and a time column ("HH:mm:ss").
I did not change the format of these columns manually. Therefore, it remains the default. MOSCOW
time . Tell me, please, how should a function look like that merges the date and time into a common date-time to be added to Google Calendar? Taking into account the Moscow time zone, of course. Thank you! Well, that is, the dateTimeStart (date and time) and dateTimeEnd (also date and time) options will go to the Calendar. How to generate these dateTimeStart and dateTimeEnd?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aleksei Shebanits, 2021-01-21
@shebanits

let date = Utilities.formatDate(new Date(), "GMT+3", 'dd.MM.yyyy');
https://24timezones.com/chasovoy-poyas/gmt#gref

A
Alexander Ivanov, 2021-01-21
@oshliaer

Dates and times in Spreadsheets are simply added together. The best thing in this situation is to have a column with the sum between "dd.MM.yyyy"and "HH:mm:ss".
To get a valid Date object, it will be enough to take the value from the final cell.

const dateTimeStart = sheets.getRange('C1').getValue();

Where you come from dateTimeEnd- only you know, but in the end, the resulting one dateTimeStartis suitable for passing as argument values ​​to methods CalendarApp.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question