Convert XMP Date and Time
Hi, in my script I am trying to read the Date and Time using the XMP functions of a selected file in bridge. Then, I want to convert that date and time into a format that looks like: "01/12/10 | 01:23 PM" and write that to another metadata field like the description. Im stuck on trying to convert the date and time into what I want it to look like? Can anyone help, thanks!
Here is the part of the code I'm having trouble with:
When I read the dateTimeOriginal property of the file, it is in an unfriendly format. It looks odd and shows the time zone. The commented lines is code that I have tried, but didn't work. I was trying to convert the XMPDateTime object into a Date object so I can adjust the format, but I haven't been successful.
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var Name = myXmp.getProperty(XMPConst.NS_EXIF, "DateTimeOriginal");
var date = new XMPDateTime(new Date(Name));
var date2 = new Date(date);
//dateFormat.masks.portfolioDate = 'mm/dd/yy "|" hh:MM TT';
//date.format("portfolioDate");
//date2.format("mm/dd/yy");
alert(date2.toString());
Name.convertToLocalTime();
Name.toString();
alert(Name);