#How to get formatted date value in {{...}} ?
1 messages · Page 1 of 1 (latest)
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:
- Create a new JSObject.
- 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;
}
}
- 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.
✅ solution: just create that function in utils.js and call it on the UI