-
-
Notifications
You must be signed in to change notification settings - Fork 18
date_time
CryoEagle edited this page Dec 27, 2018
·
3 revisions
Returns a string containing a time or date.
DateTime.Now.ToString(format)
Argument | Description |
---|---|
string format |
Format of date or time to return |
Returns: string
This function returns a string containing the time based on the input format code and can then be displayed.
Day of Month
Format | Description | Return |
---|---|---|
d | Numeric, with leading zeros | 01–31 |
j | Numeric, without leading zeros | 1–31 |
S | The English suffix for the day of the month | st, nd or th in the 1st, 2nd or 15th. |
Weekday
Format | Description | Return |
---|---|---|
l | Full name (lowercase 'L') | Sunday – Saturday |
D | Three letter name | Mon – Sun |
Month
Format | Description | Return |
---|---|---|
m | Numeric, with leading zeros | Sunday – Saturday |
n | Numeric, without leading zeros | 1–12 |
F | Textual full | January – December |
M | Textual three letters | Jan - Dec |
Year
Format | Description | Return |
---|---|---|
Y | Numeric, 4 digits | Eg., 1999, 2003 |
y | Numeric, 2 digits | Eg., 99, 03 |
Time
Format | Description | Return |
---|---|---|
a | Lowercase | am, pm |
A | Uppercase | AM, PM |
g | Hour, 12-hour, without leading zeros | 1–12 |
h | Hour, 12-hour, with leading zeros | 01–12 |
G | Hour, 24-hour, without leading zeros | 0-23 |
H | Hour, 24-hour, with leading zeros | 00-23 |
i | Minutes, with leading zeros | 00-59 |
s | Seconds, with leading zeros | 00-59 |
T | Timezone abbreviation | Eg., EST, MDT ... |
string curDate = DateTime.Now.ToString("yyyy-dd-MM");
This would set string curDate value to current date in your timezone.
Back to Maths