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

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,152 questions

40,706 answers

573 users

How to print current time in a format string with C#

2 Answers

0 votes
using System;

class Program
{
    static void Main()
    {
        DateTime dt = DateTime.Now;
        
        string format = "MMM ddd d HH:mm yyyy";
        
        Console.WriteLine(dt.ToString(format));
    }
}




/*
run:

Sep Fri 11 07:49 2020

*/

 





answered Sep 11, 2020 by avibootz
edited Sep 11, 2020 by avibootz
0 votes
using System;

class Program
{
    static void Main()
    {
        DateTime dt = DateTime.Now;
        
        string format = "M d h:mm yy";
        
        Console.WriteLine(dt.ToString(format));
    }
}




/*
run:

9 11 8:33 20

*/

 





answered Sep 11, 2020 by avibootz
edited Sep 11, 2020 by avibootz

Related questions

1 answer 44 views
1 answer 70 views
1 answer 20 views
1 answer 39 views
...