Appearance
Date formulas
Date formulas are useful to manipulate date objects inside WeWeb.
Where to find date formulas
Date formulas are built into every WeWeb project, so there is nothing to install. You'll be able to see all the related no-code formulas in the Date category of the Formulas tab of the binding window:

TIP
Working with dates can be tricky at first. If you get stuck on formatting, we recommend you go through this article on the ISO date format.
date
If you use date in a formula with no parameters, you will get the current date and time in Coordinated Universal Time (i.e. the UTC timezone).
The no-code date formula can take the same parameters as the JavaScript new Date() function.
dateRealtime
Same as date, dateRealtime will return the current date and time in Coordinated Universal Time (i.e. the UTC timezone).
That date, however, will be updated every second in real-time:

toDateISO
This formula allows you to set a date in ISO format. It only takes one parameter: the date.

If you want to display the date in a specific format, use the formatDate formula instead.
formatDate
This formula allows you to format a date:

In the example above, you see:
- First we start with a
dateformula that returns a date in ISO format, - Then we wrap the
formatDateformula around it, which displays the date asYYYY-MM-DDwhen no format is given, - We add a second parameter to the
formatDateformula to display the date in a different format, - Finally, we change the display language to Spanish. When you don't set a language, WeWeb uses the current language of your app.
Here are the codes you can use in the format:
| Code | Shows | Example |
|---|---|---|
YYYY / YY | Year | 2024 / 24 |
MMMM / MMM | Month name, full or short | March / Mar |
MM / M | Month number, with or without a leading zero | 03 / 3 |
DD / D | Day of the month, with or without a leading zero | 09 / 9 |
dddd / ddd / dd | Day of the week, full, short or narrow | Saturday / Sat / S |
HH / H | Hour, 24-hour clock | 14 |
hh / h | Hour, 12-hour clock | 02 / 2 |
mm / m | Minutes | 30 |
ss / s | Seconds | 45 |
SSS | Milliseconds | 250 |
A / a | AM or PM | PM / pm |
To show text as it is, put it between square brackets. For example, "[Today is] dddd" returns Today is Saturday.
WARNING
Codes are case sensitive. MM is the month and mm is the minutes, so make sure to write HH:mm and not HH:MM to display the hour and minutes.
toTime
This formula calculates the time between now and X, and returns the information in text format:

In the toTime formula, the relative time compares the date now, to the date in the first parameter.
For example, if today is August 23rd, 2024:
- June 23rd, 2024 was "2 months ago"
- June 23rd, 2025 is "in 10 months"
The formula will accept the following parameters:
- A date in ISO format (required),
- Whether to remove the suffix ("ago" or "in") or not (optional), and
- The language in which the text should be displayed (optional)
fromTime
This formula returns the same result as toTime: it calculates the time between X and now, and returns the information in a text format.
For example, if today is August 23rd, 2024:
- June 23rd, 2024 was "2 months ago"
- June 23rd, 2025 is "in 10 months"
The formula will accept the following parameters:
- A date in ISO format (required),
- Whether to remove the suffix ("ago" or "in") or not (optional), and
- The language in which the text should be displayed (optional)
compareDate
This formula allows you to compare two dates:

The result is the second date minus the first date, so it is negative if the second date is earlier.
You can count the number of:
- Years (
year), - Months (
month), - Weeks (
week), - Days (
day), - Hours (
hour), - Minutes (
minute), - Seconds (
second), or - Milliseconds (
millisecond), which is the default when you leave the unit empty.
TIP
When you hover over a no-code formula name in the WeWeb, you can view tooltips on what parameters and values it expects.
By default, the result of the compareDate formula will be a round number.
If the floating parameter is true, you can see decimals in the calculation. For example, there are 4.6 months between November 4th, 2023 and March 23rd, 2024:

When counting in months, a month is about 30.4 days, and when counting in years, a year is 365 days.
getX
These formulas allow you to get one part of a date, as a number. If you leave the date empty, they use the current date and time:
getSecond— the seconds, from 0 to 59getMinute— the minutes, from 0 to 59getHour— the hour, from 0 to 23getDay— the day of the month, from 1 to 31getDayOfWeek— the day of the week, from 0 (Sunday) to 6 (Saturday)getMonth— the month, from 1 (January) to 12 (December)getYear— the year, e.g.2024getDayOfYear— the day of the year, from 1 to 366getWeekOfYear— the week of the year
These formulas use the timezone of your user's browser.
addX
These formulas allow you to add time to a date, and return the new date in ISO format. The first parameter is the date, the second is the amount to add. Use a negative amount to go back in time:
addSecondsaddMinutesaddHoursaddDaysaddMonthsaddYears
For example, addDays("2024-03-23T00:00:00Z", 7) returns "2024-03-30T00:00:00.000Z".
addWorkdays
The addWorkdays formula allows you to add working days to a date, skipping weekends (Saturday and Sunday). It's useful to calculate a delivery date or a deadline.
The formula will accept the following parameters:
- A date (required),
- The number of working days to add (required). It must be a whole number, and you can use a negative number to go back in time, and
- Holidays to skip (optional), as a list of dates like
["2024-12-25", "2025-01-01"]or as text separated by commas like"2024-12-25,2025-01-01". Each holiday must be written asYYYY-MM-DD
For example, addWorkdays("2024-05-24T12:30:00Z", 1, "2024-05-27") returns "2024-05-28T12:30:00.000Z": May 24th is a Friday, the weekend is skipped, and May 27th is a holiday.
The time of day stays the same, and you can add up to 10,000 working days.
workdayDiff
The workdayDiff formula allows you to count the working days between two dates, without weekends and holidays.
The formula will accept the following parameters:
- The start date (required),
- The end date (required), and
- Holidays to skip (optional), in the same format as for
addWorkdays
Both the start date and the end date are counted. For example, from Monday to Friday of the same week, the result is 5. If the end date is before the start date, the result is negative.
setX
These formulas allow you to replace one part of a date, and return the new date in ISO format. The first parameter is the date, the second is the new value:
setSecondsetMinutesetHoursetDay— the day of the monthsetDayOfWeek— from 0 (Sunday) to 6 (Saturday), within the same weeksetMonth— from 1 (January) to 12 (December)setYear
For example, setMonth("2024-03-23T00:00:00Z", 12) returns a date in December 2024.
toTimestamp
The toTimestamp formula expects a date in ISO format and will return the timestamp value for that date in a number format:

getBrowserTimezone
The getBrowserTimezone formula will return the timezone your user's browser is in.

convertDateTimezone
The convertDateTimezone formula allows you to display a different date and time depending on the user's timezone.
The first parameter must be a date that contains time and timezone information. The second parameter is the timezone, e.g. "America/New_York".
For example, the date formula returns the date and time in the UTC timezone. Here, we are converting the current date and time to the date and time in New York:

The result will show the date and time in the new timezone, written as YYYY-MM-DDTHH:mm:ss, without timezone information.
formatDateTimezone
The formatDateTimezone formula allows you to take a date provided in ISO format, and display it:
- In the format of your choice, e.g.
"MMMM D, YYYY - HH:mm", with the same codes asformatDate(YYYY-MM-DDby default) - Converted to the timezone of your choice, e.g.
"America/Mexico_City"(the timezone of your user's browser by default) - In the language of your choice, e.g.
esfor Spanish (the current language of your app by default)

Troubleshooting
Working with dates can be tricky at first.
Here are a few things to consider when a date formula is not behaving as you would expect:
ISO date values and date formats should be strings. Make sure to enclose them in between quotes
"like_this"Timestamp values should be numbers. If you are storing timestamps in a text format, use the
toNumberformula around it to convert it so the date formulas can work with itISO date formats are easy to mess up. When in doubt, check out this article with numerous examples of ISO date formats
Format codes are case sensitive:
MMis the month andmmis the minutesHolidays in
addWorkdaysandworkdayDiffshould be written asYYYY-MM-DD, without a time

