Help / WLanguage / WLanguage functions / Standard functions / Date and time functions
  • Time validity
  • Time format
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
TimeToString (Function)
In french: HeureVersChaîne
Converts a time to a string in the specified format.
// Convert the specified time according to the "HH:MM:SS:CC" format
TimeToString("12005956")   // Returns "12:00:59:56"
Left(TimeToString("12005956"), 5) // Returns "12:00"
WEBDEV - Server codePHPAjax
// Convert the time specified according to the format: "It is: HH h MM"
TimeToString(Now(), "It is: HH h MM") // Returns "It is: 12 h 32"
WEBDEV - Server codePHPAjax
TodaysDate is Date = DateSys()
EDT_EditDate = DateToDayInAlpha(TodaysDate) + " " + TodaysDate.Day + ...
" " + DateToMonthInAlpha(TodaysDate) + " at " + ...
TimeToString(TimeSys(), "HH:MM:SS")
// The EDT_EditDate control contains for example: Monday 20 August at 14:44:17
<Result> = TimeToString(<Time to convert> [, <Format>])
<Result>: Character string
Character string in the specified format.
<Time to convert>: Character string, Date or DateTime variable
Time to use. This time can correspond to:
  • a character string in HHMMSSCC format (HH corresponds to hours, MM to minutes, SS to seconds and CC to hundredths of a second).
  • a character string in YYYYMMDDHHmmSSCC format (YYYY corresponds to the year, MM to the month, DD to the day, HH to hours, mm to minutes, SS to seconds and CC to hundredths of a second). In this case, only the time is taken into account.
  • a Time variable.
  • a DateTime variable. In this case, only the time is taken into account.
<Format>: Optional character string
Format that must be applied to the time. This parameter corresponds to:
  • a character string (a sentence for example). The specific characters representing the different elements of the time (HH, MM, SS, CC or AP) will be automatically replaced with their value identified in the <Time> string. In this string:
    • 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,
    • AP represents "AM" or "PM" (if "AP" is used, the time is displayed in 12-hour format).
  • the maskSystemTime constant. This constant allows you to directly use the mask used by the system time.
If this parameter is not specified, the result is in HH:MM:SS:CC format.

Time validity

The time validity passed as parameter is checked. A message is displayed if the time is invalid. You can check the validity of a time using TimeValid.
Tip: To have a valid time in a string, the time must be entered in a Time Edit control.

Time format

TimeToString is used to format a time returned by IntegerToTime or TimeSys. The result can be assigned to a text control, for example.
Business / UI classification: Neutral code
Component: wd290std.dll
Minimum version required
  • Version 9
This page is also available for…
Video TimeToString


08 May 2019

Last update: 05/26/2022

Send a report | Local help