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,924 questions

51,857 answers

573 users

How to format DateTime into a string with a single-character format strings in VB.NET

1 Answer

0 votes
Imports System
 
Public Class Test
    Public Shared Sub Main()
        Dim dt As DateTime = DateTime.Now
        
        Console.WriteLine(dt.ToString("d"))
        Console.WriteLine(dt.ToString("D"))
        Console.WriteLine(dt.ToString("f"))
        Console.WriteLine(dt.ToString("F"))
        Console.WriteLine(dt.ToString("g"))
        Console.WriteLine(dt.ToString("G"))
        Console.WriteLine(dt.ToString("m"))
        Console.WriteLine(dt.ToString("M"))
        Console.WriteLine(dt.ToString("o"))
        Console.WriteLine(dt.ToString("O"))
        Console.WriteLine(dt.ToString("s"))
        Console.WriteLine(dt.ToString("t"))
        Console.WriteLine(dt.ToString("T"))
        Console.WriteLine(dt.ToString("u"))
        Console.WriteLine(dt.ToString("U"))
        Console.WriteLine(dt.ToString("y"))
        Console.WriteLine(dt.ToString("Y"))
    End Sub
End Class
 
 
 
 
' run:
' 
' Friday, October 9, 2020
' Friday, October 9, 2020 1:33 PM
' Friday, October 9, 2020 1:33:19 PM
' 10/9/2020 1:33 PM
' 10/9/2020 1:33:19 PM
' October 9
' October 9
' 2020-10-09T13:33:19.9994140+00:00
' 2020-10-09T13:33:19.9994140+00:00
' 2020-10-09T13:33:19
' 1:33 PM
' 1:33:19 PM
' 2020-10-09 13:33:19Z
' Friday, October 9, 2020 1:33:19 PM
' October 2020
' October 2020
'

 



answered Oct 9, 2020 by avibootz

Related questions

1 answer 178 views
2 answers 187 views
1 answer 174 views
1 answer 169 views
1 answer 178 views
1 answer 164 views
...