Google Sheets – Fix Inconsistent Datetime Formats

google sheets

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?

Best Answer

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.