GetCurrentTime
string GetCurrentTime(string format)Description
Returns the current local time as a formatted string.
The format parameter uses strftime-style specifiers to define the output layout.
Parameter
- format - A format string using the following specifiers:
| Specifier | Description | Example |
|-----------|-------------|---------|
| %H | Hour, 24-hour clock (00–23) | 14 |
| %I | Hour, 12-hour clock (01–12) | 02 |
| %M | Minutes (00–59) | 35 |
| %S | Seconds (00–59) | 07 |
| %p | AM / PM | PM |
| %X | Full time representation | 14:35:07 |
Returns
The current time formatted as a string.
Example
void main()
{
string t1 = GetCurrentTime("%H:%M:%S"); // e.g. "14:35:07"
string t2 = GetCurrentTime("%I:%M %p"); // e.g. "02:35 PM"
}