Use workflow to format a timestamp string to date picker

Hi folks,

I’d like your help on how may I build this workflow.. We use an app called Clearout for verifying the email status.

One of the default properties (Single Line text format) synced to Hubspot is “Clearout verified on” wich contains a timestamp string

2023-10-18T12:25:12.590Z

I’d like to build a custom code workflow where I can use this value and format it as Date Picker so it can be used on reports/lists.

How may I do that?

Thanks!

Hey @LDeBenedetti, I hope that you are doing well!
It’s a pleasure to see you asking on the Community!
You’d like to use a custom code in a workflow to format a timestamp string to date picker, right?
I found these threads that might be of interest to you:
- The solution from @Bryantworks on this post “Simple String to Date Workflow using Custom Code
- The solution from @Kevin-C on this post “String date to date property in automation/workflow with custom code
I also wanted to invite a couple of subject matter experts to this conversation @HFisher7, @ChrisoKlepke and @ChristinaKay do you have any advice to help @LDeBenedetti, please?
If anybody else has anything to add and/or share, please feel free to join in the conversation :slightly_smiling_face:
Thank you and have a fabulous day!
Best,
Bérangère

Hey,

Thanks for your response.. here’s what I got but still on error…

exports.main = async (event, callback) => {

const co_vryon = event.inputFields[‘co_vryon’];

const date = new Date(co_vryon);

const co_vryon = date.toISOString();

console.log(co_vryon);

callback({ outputFields: {

date: clearout_verified_date

}

});

}

co_vryon is a single line text property containing the timestamp 2023-10-19T08:32:23.279Z

clearout_verified_date is a property with format date picker

Any suggestions?

Hi,
As per documentation, HubSPot accepts Date Picker date format as YYYY-MM-DD
HubSpot Developer Documentation - HubSpot docs)
You have from Clearout timestamp in format as 2023-10-18T12:25:12.590Z

let timestamp = "2023-10-18T12:25:12.590Z"
let datePicker = timestamp.split('T')[0]

console.log(datePicker)

That should work

let unixTimestamp = "1698156364"
let date = new Date(parseInt(unixTimestamp *1000))
 let datePicker = date.toISOString().split('T')[0]
console.log(date)
console.log(datePicker)

If you would have timestamp as as Unix format then you need to convert it

let unixTimestamp = "1698156364"
let date = new Date(parseInt(unixTimestamp *1000))
 let datePicker = date.toISOString().split('T')[0]
console.log(date)
console.log(datePicker)