UTC Date Time Conversion to Local Time: File Import

Gold Contributor
Gold Contributor

Hi

We have date time coming in thru FIle import and would liek to convert it to Local time.

Issue: 1st Mar Local time becomes 28th Feb in GMT. Incorrect audience rule calculation.

Has anyone been able to convert or come sup with a solution where GMT time can be passed and it's converted to local time for audience valuation?

 

Thanks

Samrat

1 REPLY 1

UTC Date Time Conversion to Local Time: File Import

Tealium Employee

Hi Samrat,

This is possible with our release of data transformations, however, it does not currently work with the File Import data source. This is a request that is being considered by our product team.

In the meantime, you can set up a transformation for other data sources with the following code to add a "local_timestamp" variable to your data:

// "transform" function allows you to access event and apply changes
transform((event) => {
    //const current_date = new Date();  //Instead of creating a new date, you can use the date being sent by the file import, shown below  
    const current_date = event.data.udo.imported_date;    
var _localOffset = 8*60*60*1000; //Replace the first number with your local offset (ex: Pacific Standard Time would show "8" because PST is 8 hours behind UTC) var local_timestamp = new Date(current_date.getTime() - _localOffset); event.data.udo.local_timestamp = local_timestamp.toISOString(); console.log("Local Time: " + JSON.stringify(event.data.udo.local_timestamp)); })

This code will add a new variable to your event titled "local_timestamp" which will show local time in the following string format:

"2022-07-12T15:48:29.990Z"

Please stay tuned to our Announcements Blog for more information on upcoming product features and releases. 

Thanks,

Jen

Jen Kaye
Senior Customer Success Engineer | Tealium, Inc.
Public