Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,890 questions

51,821 answers

573 users

How to convert today's date and time to string with different formats switch C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        DateTime now = DateTime.Now;
        
        Console.WriteLine("1. " + now.ToString("d"));
        Console.WriteLine("2. " + now.ToString("D"));
        Console.WriteLine("3. " + now.ToString("F"));
        Console.WriteLine("4. " + now.ToString("M"));
        Console.WriteLine("5. " + now.ToString("o"));
        Console.WriteLine("6. " + now.ToString("R"));
        Console.WriteLine("7. " + now.ToString("t"));
        Console.WriteLine("8. " + now.ToString("T"));
        Console.WriteLine("9. " + now.ToString("Y"));
    }
}




/*
run:

1. 7/8/2023
2. Saturday, July 8, 2023
3. Saturday, July 8, 2023 6:26:31 AM
4. July 8
5. 2023-07-08T06:26:31.3717340+00:00
6. Sat, 08 Jul 2023 06:26:31 GMT
7. 6:26 AM
8. 6:26:31 AM
9. July 2023

*/

 



answered Jul 8, 2023 by avibootz

Related questions

1 answer 138 views
1 answer 149 views
1 answer 106 views
1 answer 143 views
1 answer 166 views
1 answer 159 views
...