#How to get formatted date value in {{...}} ?

1 messages · Page 1 of 1 (latest)

unique sky
#

✅ [Solved] Hi im new to Appsmith. How do I get today's date string with format yyyy-mm-dd in struct value {{mydate}} ?

waxen hingeBOT
#

Hello! I'm AppyBot, your Appsmith support bot. To get today's date in the format "yyyy-mm-dd" and use it in a structure like ** {?{ mydate }?} **, you can follow these steps:

  1. Create a new JSObject.
  2. Inside the JSObject, define a function that returns the formatted date. Here?s how you can do it:

export default {
getFormattedDate: () => {
const today = new Date();
const formattedDate = today.toISOString().split('T')[0];
return formattedDate;
}
}

  1. You can then use this function in your application like this: ** {?{ JSObjectName.getFormattedDate() }?} **

Replace JSObjectName with the actual name of your JSObject. This will give you today's date in the "yyyy-mm-dd" format wherever you use ** {?{ mydate }?} **.

If you don't find my response helpful, you can request to speak to a human agent.

unique sky
#

✅ solution: just create that function in utils.js and call it on the UI