Format any date to match the user's locale settings with this Client Script

Format any date to match the user's locale settings with this Client Script

A common problem in Zoho Client Script is a user's date format. On Create/Edit pages, Zoho will only accept a date if it matches the user's locale. Even if the date is in a correct format, or Zoho date format, user's can't save a record if the date format entered doesn't match the user's settings.

There's a few ways around this:

  1. Make all users use the same date format
  2. Update dates after a record is saved with deluge
  3. Manually require users to use the date picker
  4. Use my method below
Attached is a script for you to download. You will need the change the file extension to .js before proceeding.

Go to Client Script --> Static Resources



Click 'New Resource' and follow the prompts to upload the file I've given you.



Now in your client script, click on Static Resources and click 'Add' next to the resource you just added






Now to format your date, simply call the function within the static resource like this:

  1. log(formatDate(new Date,$Crm.user.date_format))

The function needs two parameters. The date, and the date format. In this instance, I'm getting the date format from the user details so it will dynamically format the date to whatever format the user has set with 1 line of code within your Client Script.