Skip to main content
Known Participant
March 4, 2015
Question

How do you convert an event timestamp to an XMP formatted date?

  • March 4, 2015
  • 1 reply
  • 419 views

In an event listener you can query for the current time:

var myTimeStamp = myEvent.timeStamp

Which gives you

Tue Mar 03 2015 22:11:23 GMT-0600

However to write this to an XMP date field you need to convert it to an iso8601 Date

A string containing a date-time in ISO 8601 format; for example:

"2007-04-10T17:54:50+01:00"

Is there any clear cut way to do this?

James Haney

This topic has been closed for replies.

1 reply

Known Participant
March 4, 2015

I found out that I can call:

var myTimeStamp = new XMPDateTime(new Date());

which results in:

2015-03-03T22:56:45.558-06:00

This is a date object and not a string. Good so far.

However, when I call my function "mySetXMP" with the following parameters:

mySetXMP("http://ns.adobe.com/xap/1.0/","LCCRevisionTime","LCCRevisionTime", myTimeStamp,"XMPConst.XMPDATE");

function mySetXMP(xmpNS,xmpFieldName,xmpFieldTarget,myValue,myVarType){ 

var myDocument = app.activeDocument;

with(myDocument.metadataPreferences){

var myNewContainer = createContainerItem(xmpNS, xmpFieldName);

setProperty(xmpNS, xmpFieldTarget, myValue, myVarType);

}

}

The script bails out with the setProperty line hilighted in ExtencScript.

Inspiring
March 4, 2015

Hi,

Did you try converting the Date object to String in the setProperty function ?

Loic

http://www.ozalto.com

Known Participant
March 4, 2015

It still throws an error.