Skip to content

Feature suggestion: Timezone support for datetime() renderer #289

@xJuvi

Description

@xJuvi

Hey there,

i store all timestamps as unix timestamp in my database. When i display them in a form or other page, they will be displayed in UTC+2 (german summertime). Since a few weeks i doesn't convert the timestamps before i display them with datatables. But all timestamps will be displayed in UTC+0. So the time is two hours in the past.

I tried a look in the renderer source code.....

function __mldObj (d, format, locale) {
var dt;
resolveWindowLibs();
if (__moment) {
dt = __moment.utc( d, format, locale, true );
if (! dt.isValid()) {
return null;
}
}
else if (__luxon) {
dt = format && typeof d === 'string'
? __luxon.DateTime.fromFormat( d, format )
: __luxon.DateTime.fromISO( d );
if (! dt.isValid) {
return null;
}
dt.setLocale(locale);
}
else if (! format) {
// No format given, must be ISO
dt = new Date(d);

I think where wo use luxon or moment it was very easy to convert the time object in another timezone. The are several ways possible. As fourth parameter we can add the destination timezone. And if we want, we can also add a fifth parameter as current timezone.

Are there any plans for this? Is it allowed to make a short pull request to add this feature? I really need it. Otherwise the datetime renderer isn't useful for me and i need to write my own one. But my suggested changes are no breaking changes and maybe will help some other people.

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions