Moment.utc() does not work in the map JS function

I have a bulk upsert query for my table.
and what I want to do is update the updated_at timestamp to the current UTC timestamp.

so I wrote this JS map

  row.updated_at = moment.utc()
  return row

But the moment.utc() does not work and I get error:
Unexpected token F in JSON at position 0

other functions like works fine.

Can any one please help?

Hey @gal_polak, welcome to the community :hugs:

try moment.utc().format().

1 Like

Thank you very much for welcoming me, I'm an old user that came back :smiley:

It works..!!

Maybe you can explain why? just to expand my knowledge

1 Like

Welcome back then :))

just .utc() returns an object, while .format() returns a string. The new Date() is also an object, however a Date object. To get a native Date object returned from moment you'll have to use .toDate().

Both .toDate() and .format() work.

I had the same issue previously and figured that out.

1 Like

Thank you very much!!

1 Like