UTC vs Local time zone

Are you sure the Date taken column is not image-local, but pc-local?

A custom column can display datetaken in UTC:

function OnInit(initData) {
    initData.name = 'Date taken UTC';
    initData.version = '2021-07-17';
    initData.url = 'https://resource.dopus.com/t/utc-vs-local-time-zone/39824';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddColumns(addColData) {
    var col = addColData.AddColumn();
    col.multicol = true;
    col.method = 'OnColumn';
    col.name = 'Date taken (UTC)';
    col.label = 'Date taken (UTC)';
    col.header = 'Date taken (UTC)';
    col.justify = 'right';
    col.defwidth = 6;
    col.autorefresh = 1;
    col.autogroup = true;
    col.type = 'datetime';

    var col = addColData.AddColumn();
    col.multicol = true;
    col.method = 'OnColumn';
    col.name = 'Date taken (local)';
    col.label = 'Date taken (local)';
    col.header = 'Date taken (local)';
    col.justify = 'right';
    col.defwidth = 6;
    col.autorefresh = 1;
    col.autogroup = true;
    col.type = 'datetime';
}

function OnColumn(scriptColData) {
    var dt = scriptColData.item.metadata.image.datetaken;
    var isDate = DOpus.Typeof(dt) == 'object.Date';
    
    scriptColData.columns('Date taken (UTC)').value = isDate ? dt.ToUTC() : '';
    
    // scriptColData.columns('Date taken (local)').value = isDate ? dt.ToUTC().FromUTC() : '';
    scriptColData.columns('Date taken (local)').value = isDate ? dt.Format('D#yyyy-MM-dd T#HH:mm:ss') : '';
}

I've included a Date taken (local) column as demo, however, I can't think of a simple way to compute the values.

ColumnDateTakenUTC.js.txt (1.4 KB)


How to use buttons and scripts from this forum

1 Like