This is a draft cheat sheet. It is a work in progress and is not finished yet.
Date string
Datetime.Now |
Datetime variable |
Datetime.Now.ToString() |
“dd/MM/yyyy hh:mm:ss” |
|
Day Formats
Datetime.Now.ToString(“dd”) |
Numerical Day (e.g 09) |
Datetime.Now.ToString(“dddd”) |
Full Day Name (e.g Wednesday) |
|
Month Formats
Datetime.Now.ToString(“MMM”) |
Three Char Month (e.g Feb) |
Datetime.Now.ToString(“MM”) |
Numerical Month (e.g 02) |
|
Year Formats
Datetime.Now.ToString(“yyyy”) |
Full Year (e.g 2024) |
Datetime.Now.ToString(“yy”) |
Two Char Year (e.g 24) |
|
Convert String to Date
Convert.ToDatetime(str_Input) |
str_Input = “12/02/2024” |
Datetime.Parse(str_Input ) |
str_Input = “12/02/2024” |
|
Current Time Format
Datetime.Now.ToString(“hh:mm:ss”) |
12 hour format |
Datetime.Now.ToString(“HH:mm:ss”) |
24 hour format |
Datetime.Now.ToString(“hh”) |
12 hour format Hour only |
Datetime.Now.ToString(“HH”) |
24 hour format Hour only |
Datetime.Now.ToString(“mm”) |
Current minutes only |
Datetime.Now.ToString(“ss”) |
Current seconds only |
Datetime.Now.ToString(“dd/MM/yyyy hh:mm:ss K”) |
Current Time with Timezone (e.g 09/10/2024 02:08:02 +01:00) |
Datetime.Now.ToString(“dd/MM/yyyy hh:mm:ss tt”) |
Current time with AM/PM |
|