Standard DateTime Format Strings
String.Format("{0:u}", DateTime.Now); // Result: "2005-07-26 15:48:16Z"
For more codes, look up “Standard DateTime Format Strings“.
Can also be used like this:
DateTime.Now.ToString("u");
More examples:
timevar.ToString("yyyy-MM-dd HH:mm");
Custom DateTime Format Strings
String.Format("{0:%d}/{0:%M}", DateTime.Now) ; String.Format("{0:%d'/'%M}", DateTime.Now); // Same result for both: "26/7"
“%” is needed for these codes to guarantee that Custom codes are used. The codes ‘d’ and ‘M’ also namely also exists as Standard codes, but with other meanings.
For more codes, look up “Custom DateTime Format Strings“.
Can also be used like this:
DateTime.Now.ToString("%d'/'%M");