0
votes

I state that I am not a programmer but I'm learning Google Apps Script ScriptDb applied to the database. Say immediately that most of my time (long time) I lose with the use of dates. There is so much. example: In a document form I enter a date, that being in Italy, I propose in the format dd / mm / yyyy eg 10/06/1940 I write to the database with the following ScriptDb iscruzioni:

 var dNascita = new Date (BirthDate); 
 ...
 {BirthDate: dNascita.getTime ()} 

Then I read from the database ScriptDb:

 var dbDatanascita = new Date (result.DataNascita); 

But the date is different from the one entered in the input (06.10.1940).

Where can I learn how to read and write dates in the format dd / MM / yyyy and in particular on the database ScriptDb?

Thank you

raffaele

2

2 Answers

0
votes

See the example given here.

var date = new Date('1/1/2014');
var item = {
  timestamp: date.getTime();
}
var record = db.save(item);

var date = new Date(record.timestamp);

Please give you entire code so we can check what's happening during the date retrieve.

0
votes

You have 2 errors: 1) in your line 1, Date() doesnt accept any format. 2) in your last line, you are not taking the timezone into account so you can end up on the day before or after. Read about javascript dates on any tutorial page. Gas also has date utility functions.