0

In My database, I have following values for a column:

created_at: 2018-11-29 00:24:33.967124

But when I query this column to get its data in nodeJS, it returns following data:

created_at: 2018-11-29T00:24:33.967124Z

I do not know who is the culprit here, if it is nodejs/ postgres or timezone.

To explain more here is my query:

let query = "Select created_at from my_table limit 1";

let tableData = await runQuery(query);
console.log(tableData);

Output: [{ created_at: 2018-11-28T19:24:20.946Z }]

So I do not want node to convert/ format this data and retun the data as it is from database. How I can do that or what I am doing wrong.

undefined
  • 3,464
  • 11
  • 48
  • 90

1 Answers1

0

Those are the same. Timestamp with zero timezone is the same as timestamp without timezone. And Node.js driver will always give you timestamps with timezone.

const a = Date.parse('2018-11-29T00:24:33.967124Z');
const b = Date.parse('2018-11-29 00:24:33.967124');

console.log(a); //=> 1543451073967
console.log(b); //=> 1543451073967

console.log(a === b); //=> true
vitaly-t
  • 24,279
  • 15
  • 116
  • 138