ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Date and time functions
  • Validity of the date
  • Date format
  • Special case: is not specified
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Converts the specified date to the specified format.
Tip: If the formatted date contains the "/" characters, it must not be displayed it in a Date edit control.
Example
MaDate est une Date
MaDate = "20191225"
Res = MaDate.VersChaîne()  // Res = "25/12/2019"
Res = MaDate.VersChaîne("MM-JJ-AAAA") // Res = "12-25-2019"
Res = MaDate.VersChaîne("Le numéro du jour JJ du mois n° MM de l'année AAAA")
MaDate = DateSys()
Res = MaDate.VersChaîne(maskDateSystème)
// Res utilise le format défini dans le projet
MaDate est une Date
MaDate = "20031202"
// La casse des jours et mois en lettres est dépendante des options linguistiques du projet
Res = MaDate.VersChaîne("JJJ JJ MMM AAAA")
// Res = "mar. 02 déc. 2003" ou "Mar. 02 Déc. 2003"
Res = MaDate.VersChaîne("JJJJ JJ MMMM AAAA")
// Res = "mardi 02 décembre 2003" ou "Mardi 02 Décembre 2003"
//--------
// La casse des jours et des mois est forcée avec une majuscule
Res = MaDate.VersChaîne("Jjj JJ Mmm AAAA") // Res = "Mar. 02 Déc. 2003"
Res = MaDate.VersChaîne("Jjjj JJ Mmmm AAAA") // Res = "Mardi 02 Décembre 2003"
MaDate est une Date
MaDate = "20191125"
Res = MaDate.VersChaîne(maskDateEmail)
// Renvoie "Mon, 25 Nov 2019 00:00:00 +0100"
Res = MaDate.VersChaîne(maskDateEmail)  
// Renvoie "Sun, 25 Aug 2019 00:00:00 +0200"
MaDate est une Date
MaDate = "20121125"
Res = MaDate.VersChaîne(maskDateEmail)
// Renvoie "Sun, 25 Nov 2012 00:00:00 +0100"
Res = MaDate.VersChaîne(maskDateEmail)  
// Renvoie "Sat, 25 Aug 2012 00:00:00 +0200"
MaDate est une Date
MaDate = "20190101"
// A la date du 22/01/2019
Res = MaDate.VersChaîne(maskDateDuréeRelative)
// Renvoie: il y a 3 semaines
Res = MaDate.VersChaîne(maskDateDuréeRelative)
// Renvoie: dans 10 mois
Res = MaDate.VersChaîne(maskDateDuréeRelative)
// Renvoie: la semaine dernière
Syntax

Converting a date to string Hide the details

<Result> = <Date>.ToString([<Format>])
<Result>: Character string
Character string in the specified format.
<Date>: Date variable
Name of the Date variable to convert.
<Format>: Optional character string
Format of the converted date. This parameter can contain a word, a sentence, ... The characters that represent the different elements of the date (YYYY, YY, MM or DD) will be automatically replaced with the value in the <Date> parameter. In this string:
  • YYYY represents a 4-digit year,
  • YY represents a 2-digit year.
  • M represents the month without a leading zero,
  • MM represents a 2-digit month,
  • MMM represents a 3-letter month (e.g., Jan). The case used depends on the language options of the project.
  • Mmm represents a 3-letter month with the first letter in uppercase (e.g., Jan)
    PHP This notation is not available.
  • mmm represents a 3-letter month with the first letter in lowercase (e.g., jan)
    PHP This notation is not available.
  • MMMM represents the month as a full name (e.g., January). The case used depends on the language options of the project.
    PHP This notation is not available.
  • mmmm represents the month as a full name with the first letter in lowercase (e.g., january)
    PHP This notation is not available.
  • D represents the day without a leading zero,
  • DD represents a 2-digit day,
  • DDD represents a 3-letter day (e.g., Mon). The case used depends on the language options of the project.
  • Ddd represents a 3-letter day with the first letter in uppercase (e.g., Mon)
    PHP This notation is not available.
  • ddd represents a 3-letter day with the first letter in lowercase (e.g., mon)
    PHP This notation is not available.
  • DDDD represents the day as a full name (e.g., Monday). The case used depends on the language options of the project.
  • Dddd represents the day as a full name with the first letter in uppercase (e.g., Monday).
    PHP This notation is not available.
  • dddd represents the day as a full name with the first letter in lowercase (e.g., monday).
    PHP This notation is not available.
  • M represents the first letter of the day (e.g., M,T,W,T,F,S,S).
    If this parameter corresponds to the constant:
    maskDateEmailThe format used corresponds to the date format of the RFC-5322 standard used to encrypt an email, an RSS feed, ...
    The result is expressed in the local time zone.
    WEBDEV - Browser codeAndroidJavaPHP Not available.
    maskDateEmailUTCThe format used corresponds to the date format of the RFC-5322 standard used to encrypt an email, an RSS feed, ...
    The result is expressed in universal time (UTC).
    WEBDEV - Browser codeAndroidJavaPHP Not available.
    maskDateInternetThe format used corresponds to the RFC-3339 standard used for international communications.
    The result is expressed in the local time zone.
    maskDateInternetUTCThe format used corresponds to the RFC-3339 standard used for international communications.
    The result is expressed in universal time (UTC).
    WEBDEV - Browser code Not available.
    maskDateRelativeDurationThis format is used to express the time elapsed (or that will elapse) between the current date and the specified date. This format is expressed in natural language. The different formulations used can be configured in the project description for the current language:
    1. On the "Project" tab, in the "Project" group, click "Description".
    2. In the "Languages" tab:
      • select the language to configure.
      • select the "Date" tab.
    3. Click the "Dates and Times in natural language" button.
    4. Define (if necessary) the custom captions to use. These captions will be used:
      • for the result of <Date type>.ToString.
      • for the controls that use the "Relative duration" display mask.
    WEBDEV - Browser code Not available.
    maskDateSystemThe format used corresponds to the format defined in the project description for the current language:
    1. On the "Project" tab, in the "Project" group, click "Description".
    2. Select the "Languages" tab then the "Date" tab.
    3. The format used corresponds to:
      • the settings of the operating system,
      • the specified parameters (with the defined days and months).

    If this parameter is not specified, the DD/MM/YYYY format is used by default.
Remarks

Validity of the date

The validity of the date passed as parameter is checked. A message is displayed if the date is invalid. You can check the validity of a date using DateValid. The date storage format allows you to store dates from 01/01/0001 to 12/31/9999.
WLanguage functions and WLanguage properties make accurate calculations on dates from January 1st, 1583.

Date format

<Date type>.ToString is used to format a date returned by IntegerToDate or DateSys. The result can be assigned to a text control, for example.
To get the date in another format, use <ANSI String type>.Right, Left, Middle, etc.

Special case: <Format> is not specified

The language options specified for dates in the project description are used if no specific format is defined.
To display the linguistic options of the project:
  1. Open the project description: on the "Project" tab, in the "Project" group, click "Description".
  2. Select the "Language" tab.
For example:
  • if the project uses the language options of Windows for the dates, the days of the week and the months will start with an Uppercase character on a computer running Windows in English.
  • if the project uses specific parameters for the dates for one or more languages (custom name of the day or month, etc.), these parameters will be taken into account for the specified language.
Component: wd290std.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/05/2023

Send a report | Local help