ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Date and time functions
  • Time validity
  • Time format
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
TimeToString (Function)
In french: HeureVersChaîne
Converts a time to a string in the specified format.
Example
// 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"
WINDEVUniversal Windows 10 AppJavaUser code (UMC)
// 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"
WINDEVUniversal Windows 10 AppJavaUser code (UMC)
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
Syntax
<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.
    Java This constant is not available.
If this parameter is not specified, the result is in HH:MM:SS:CC format.
Remarks

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…
Comments
Video TimeToString
https://youtu.be/qzkqFp0OzkI

https://windevdesenvolvimento.blogspot.com/2019/05/dicas-2102-windev-webdev-mobile-data-28.html

// BTN_FORMATAR_HORA

STC_MOSTRA_HORA_FORMATADO=TimeToString(Now(),"A Hora é HH MM")
amarildo
08 May 2019

Last update: 05/26/2022

Send a report | Local help