PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Validity of date time
  • Date time 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 a DateTime to string in the specified format.
Tip: The return value of this function must not be assigned to a "Date" Edit control (with an input mask including the date and time) that expects a string without separators (e.g.: "202004281500").
Example
Res = DateTimeToString("201912251715") // Res = "25/12/2019 17:15:00:00"
 
Res = DateTimeToString(RealToDateTime(73773,5)) // Res = "25/12/2001 00:00:00:00"
 
DateTimeToString("") // Retourne ""
 
Res = DateTimeToString("201912251715", "MM-JJ-AAAA HH:mm") // Res = "12-25-2019 17:15"
 
Res = DateTimeToString("207912251715", ...
"Le numéro du jour JJ du mois n° MM de l'année AAAA à HH heures et mm minutes")
 
Res = DateTimeToString(SysDateTime(), maskDateSystem)
// Res utilise le format défini dans le projet
 
// La casse des jours et mois en lettres est dépendante des options linguistiques du projet
Res = DateTimeToString("202012021715", "JJJ JJ MMM AAAA HH:mm")
// Res = "mer. 02 déc. 2020 17:15" ou "Mer. 02 Déc. 2020 17:15"
 
Res = DateTimeToString("202012021715", "JJJJ JJ MMMM AAAA HH:mm")
// Res = "mercredi 02 décembre 2020 17:15" ou "Mercredi 02 Décembre 2020 17:15"
 
// La casse des jours et des mois est forcée avec une majuscule
Res = DateTimeToString("202012021715", "Jjj JJ Mmm AAAA HH:mm")
// Res = "Mer. 02 Déc. 2020 17:15"
Res = DateTimeToString("202012021715", "Jjjj JJ Mmmm AAAA HH:mm")
// Res = "Mercredi 02 Décembre 2020 17:15"
 
Res = DateTimeToString("201911251715", maskDateEmail)
// Renvoie "Mon, 25 Nov 2019 17:15:00 +0100"
 
Res = DateTimeToString("201908251715", maskDateEmail)  
// Renvoie "Sun, 25 Aug 2019 17:15:00 +0200"
 
Res = DateTimeToString("201911250015", maskDateEmailUTC)
// Renvoie "Sun, 24 Nov 2019 23:15:00 +0000"
 
Res = DateTimeToString("201908251715", maskDateInternet)  
// Renvoie "2019-08-25T17:15:00.000+02:00"
 
Res = DateTimeToString("201908250015", maskDateInternetUTC)  
// Renvoie "2019-08-24T22:15:00.000Z"
 
// A la date du 02/09/2020 à 11:00
Res = DateTimeToString("202001011715", maskDateRelativeDuration)
// Renvoie: il y a 8 mois
 
Res = DateTimeToString("202011251715", maskDateRelativeDuration)
// Renvoie: l'année prochaine
 
Res = DateTimeToString("202001181715", maskDateRelativeDuration)
// Renvoie: dans 6 heures
Syntax
<Result> = DateTimeToString(<Data to convert> [, <Format>])
<Result>: Character string
Character string in the specified format.
<Data to convert>: String or Variable of type DateTime
Local date and time to convert. Can correspond to:
  • a DateTime variable.
  • a character string with one of the following formats:
    • YYYYMMDDHHmmSSCCC
    • YYYYMMDDHHmmSSCC
    • YYYYMMDDHHmmSS
    • YYYYMMDDHHmm
    • YYYYMMDDHH
    • YYYYMMDD
This parameter will be considered invalid in the following cases:
  • if the date is invalid or earlier than 01/01/1970. You can check the validity of a date using DateValid.
  • if the time is invalid. You can check the validity of a time using TimeValid.
Remark: It is possible to use dates beyond 2038.
<Format>: Optional character string
Format of the converted date and time. This parameter can contain a word, a sentence, ... The characters that represent the different elements of the date and time will be automatically replaced with the value in the <Date to convert> 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 linguistic options of the project.
  • Mmm represents a 3-letter month with the first letter in uppercase (e.g., Jan)
  • mmm represents a 3-letter month with the first letter in lowercase (e.g., jan)
  • MMMM represents the month as a full name (e.g., January). The case used depends on the linguistic options of the project.
  • Mmmm represents the month as a full name with the first letter in uppercase (e.g., January)
  • mmmm represents the month as a full name with the first letter in lowercase (e.g., january)
  • 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 linguistic options of the project.
  • Ddd represents a 3-letter day with the first letter in uppercase (e.g., Mon)
  • ddd represents a 3-letter day with the first letter in lowercase (e.g., mon)
  • DDDD represents the day as a full name (e.g., Monday). The case used depends on the linguistic options of the project.
  • Dddd represents the day as a full name with the first letter in uppercase (e.g., Monday)
    dddd represents the day as a full name with the first letter in lowercase (e.g., monday)
  • M represents the first letter of the day (e.g., M,T,W,T,F,S,S)
  • HH represents the number of hours,
  • mm represents the number of minutes,
  • SS represents the number of seconds,
  • CC represents the number of hundredths of a second,
  • CCC represents the number of thousandths of a second,
  • AP represents "AM" or "PM" (if "AP" is used, the time is displayed in 12-hour format).
If this parameter corresponds to the constant:
maskDateRelativeDurationThis format is used to express the time elapsed (or that will elapse) between the current date time and the specified date time. 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 the function DateTimeToString.
    • for the controls that use the "Relative duration" display mask.
WEBDEV - Browser code Not available.
maskDateEmailThe format used corresponds to the date time format of the RFC-5322 standard used to encrypt emails, RSS feeds, etc, ...
The result is expressed in the local time zone.
WEBDEV - Browser codeAndroidJava Not available.
maskDateEmailUTCThe format used corresponds to the date time format of the RFC-5322 standard used to encrypt emails, RSS feeds, etc, ...
The result is expressed in universal time (UTC).
WEBDEV - Browser codeAndroidJava Not available.
maskDateInternetThe format used corresponds to the date time format of the RFC-3339 standard used for international communications.
The result is expressed in the local time zone.
maskDateInternetUTCThe format used corresponds to the date time format of the RFC-3339 standard used for international communications.
The result is expressed in universal time (UTC).
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 date format used corresponds to:
    • the settings of the operating system,
    • the specified parameters (with the defined days and months).
  4. Select the "Languages" tab then the "Time" tab.
  5. The time 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 HH:mm:SS:CC format is used by default.
Remarks

Validity of date time

The validity of the date and time passed as parameters is checked. A fatal error message is displayed if the date time is invalid. You can check the validity of a date time using DateTimeValid. The date time storage format allows you to store date times between 01/01/0001 00:00:00 and 12/31/9999 11:59:59:99 PM.
WLanguage functions and properties make precise calculations on date times from January 1, 1583 00:00:00:00.

Date time format

DateTimeToString is used to format a datetime returned by RealToDateTime or SysDateTime. The result can be assigned to a text control, for example.
To get the date time in another format, you must use the following functions: Right, Left, Middle, etc.

Special case: <Format> is not specified

The language options specified for dates and times 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 linguistic 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: wd270std.dll
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment