|
<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > Date and Time > cDateTime > cDateTime_Methods > <cDateTime>.ToString |
Description
Handy function returning current date and time in a string form.
Syntax
Option 1: numeric format option
s = <cDateTime>.ToString[(lFormat)]
Option 2: string format option
s = <cDateTime>.ToString(strFormat)
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lFormat |
Numeric |
Yes |
If format parameter is numeric or missed, use one of those values to indicate return string formats. Possible other formatting types:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
strFormat |
String |
yes |
Specify style format string and return the date/time in that format, supporting placeholders like yyyy, MM, dd, HH, mm, ss, fff, tt, dddd, MMM, etc.
Warning: all placeholders are case sensitive
Supported Format Tokens
1.Locale‑aware names: "dddd" / "ddd" / "MMMM" / "MMM" returns localized day/month strings from Windows. 2.Literal text: single quotes wrap verbatim text; doubled '' becomes a single quote (like .NET). 3.Escapes: \ makes the next character literal (e.g., H\h m\m ⇒ 13h 05m). 4.AM/PM rules: 00:00:00 → 12:00:00 AM; 12:00:00 → 12:00:00 PM.
|
Remarks
Restrictions
See also
Examples
' Create an object with current date and time
Dim myDateTime As New cDateTime
' Displays the current time and date
MsgBox 0, "myDateTime is:" + $CRLF + myDateTime.toString
MsgBox 0, "myDateTime is:" + $CRLF + myDateTime.toString(10)
MsgBox 0, "myDateTime is:" + $CRLF + myDateTime.toString("yyyy/MM/dd HH:mm")