How do I convert a selected date from date picker to unix format?

---- Posted on Discord by rs4

How do I convert a selected date from date picker to Unix format?

Appsmith supports momentjs to handle date-time fields. You can use the moustache bindings anywhere across the platform for using this.

If you’re date picker widget is named DatePicker1, you can use the following syntax:

moment(DatePicker1.selectedDate).valueOf()

You could use .unix() instead of .valueOf() to display timestamp in seconds.

.valueOf(): provides unix timestamp in milliseconds
.unix(): provides unix timestamp in seconds

More docs: Moment.js | Docs

Here is a list of all the supporting libraries now: External libraries - Appsmith

1 Like