dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Timezone option for 'date' types #690

Closed pito-svk closed 8 years ago

pito-svk commented 8 years ago

I have table with 3 columns of datetime type, first is timestamp (datetime WITH time zone), the other two are datetimes WITHOUT time zone.

Is there any way to specify timezone for specific columns?

Like:

timestamp: {
   type: 'date',
   time: true,
   required: true,
   timezone: true
}

Thanks.

dxg commented 8 years ago

This isn't supported natively, however it may be possible with the use of custom types.

Given that the native Date does not have arbitrary timezone support, you'd have to pair this with something like moment-timezone.

If all you want is absolute time, it's highly recommended to store & use UTC time on all your servers.

pito-svk commented 8 years ago

Thanks. Will update these fields manually in database.