Can You Provide Code to Convert a Timestamp to Midnight UTC?

This topic was automatically generated from Slack. You can find the original thread here.

can you write me code that will convert a timestamp to midnight UTC?

Sure, here’s a Pipedream component that converts a given timestamp to midnight UTC: ```
export default defineComponent({ props: { timestamp: { type: “integer”, label: “Timestamp”, description: “Enter the timestamp you want to convert to midnight UTC”, }, }, async run({ steps, $ }) { const inputDate = new Date(this.timestamp); const midnightUTC = new Date(Date.UTC(inputDate.getUTCFullYear(), inputDate.getUTCMonth(), inputDate.getUTCDate())); return midnightUTC.getTime(); }, });

why do i get an error - inputDate.getUTCFullYear is not a function

I apologize for the confusion earlier. It seems there was an issue with the provided code. Please try this updated Pipedream component code to convert a timestamp to midnight UTC: ```
export default defineComponent({ props: { timestamp: { type: “integer”, label: “Timestamp”, description: “Enter the timestamp you want to convert to midnight UTC”, }, }, async run({ steps, $ }) { const inputDate = new Date(this.timestamp * 1000); const midnightUTC = new Date(Date.UTC(inputDate.getUTCFullYear(), inputDate.getUTCMonth(), inputDate.getUTCDate())); return midnightUTC.getTime(); }, });