2

When we push date and time values to a google spreadsheet in the format d/m/Y H:i a (eg. 25/12/2015 1:43 pm) the date and time is displayed inconsistently, see below: enter image description here

Any idea why the format is not consistent in google spreadsheets and how we can ensure it is?

2

Apparently you have a bug in the code that is forming those datetime strings: it always puts "pm" at the end. There is no such time as "15:39 pm", so Google does not parse this as a date time value, treating it just as a string (hence, left-align).

To fix this, simply drop "pm" part, since you are evidently using 24-hour time rather than 12-hour. Better yet, use ISO formatting:

2015-11-13 15:39 

which should be correctly parsed by Google Sheets independent of your locale.

  • I confirmed this with my own test. – ale Dec 3 '15 at 1:36
  • Can't believe I missed that! Thank you – Nick5a1 Dec 3 '15 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.