|
<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > Date and Time > cDateTime > cDateTime_Methods > <cDateTime>.ToStringFormat |
Description
Return current date and time in a string form using special placeholdrs.
Syntax
s = <cDateTime>.ToStringFormat(strFormat)
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
Uses "Console"
' Create an object with current date and time
Dim dt As New cDateTime
' Displays the current time and date
Printl dt.toStringFormat("yyyy/MM/dd HH:mm")
Printl dt.toStringFormat("yyyy-MM-dd HH:mm:ss.fff")
Printl dt.toStringFormat("dd/MM/yyyy 'alle' HH:mm 'ora locale'")
Printl dt.toStringFormat("dddd, MMMM d, yyyy")
Printl dt.toStringFormat("hh:mm tt") & " (12-hour with AM/PM)"
Printl dt.toStringFormat("H\h m\m s\s") & " (escaped unit letters)"
Printl dt.toStringFormat("yyyy-'Q'Q (literal ' quotes: '' )")
Printl dt.toStringFormat("ddd MMM dd HH:mm:ss yyyy")
WaitKey