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

51,825 answers

573 users

How to format datetime in different formats with VB.NET

1 Answer

0 votes
Imports System

Public Class Program
	Public Shared Sub Main()
        Dim dt As DateTime = DateTime.Now
		
        Console.WriteLine(dt.ToString("1. MM/dd/yyyy"))
        Console.WriteLine(dt.ToString("2. MMMM dd"))
        Console.WriteLine(dt.ToString("3. yyyy MMMM"))
        Console.WriteLine(dt.ToString("4. dddd, dd MMMM yyyy"))
        Console.WriteLine(dt.ToString("5. dddd, dd MMMM yyyy HH:mm:ss"))
        Console.WriteLine(dt.ToString("6. MM/dd/yyyy H:mm"))
        Console.WriteLine(dt.ToString("7. MM/dd/yyyy HH:mm"))
        Console.WriteLine(dt.ToString("8. MM/dd/yyyy hh:mm tt"))
        Console.WriteLine(dt.ToString("9. MM/dd/yyyy h:mm tt"))
        Console.WriteLine(dt.ToString("10. MM/dd/yyyy HH:mm:ss"))
        Console.WriteLine(dt.ToString("11. yyyy-MM-dd HH:mm:ss.fffffffK"))
        Console.WriteLine(dt.ToString("12. ddd dd MMM yyy HH:mm:ss GMT"))
        Console.WriteLine(dt.ToString("13. yyyy-MM-dd HH:mm:ss"))
        Console.WriteLine(dt.ToString("14. HH:mm"))
        Console.WriteLine(dt.ToString("15. HH:mm:ss"))
        Console.WriteLine(dt.ToString("16. H:mm"))
        Console.WriteLine(dt.ToString("17. hh:mm tt"))
        Console.WriteLine(dt.ToString("18. h:mm tt"))
    End Sub
End Class





' run:
'
' 1. 11/17/2021
' 2. November 17
' 3. 2021 November
' 4. Wednesday, 17 November 2021
' 5. Wednesday, 17 November 2021 07:17:21
' 6. 11/17/2021 7:17
' 7. 11/17/2021 07:17
' 8. 11/17/2021 07:17 AM
' 9. 11/17/2021 7:17 AM
' 10. 11/17/2021 07:17:21
' 11. 2021-11-17 07:17:21.2308021+00:00
' 12. Wed 17 Nov 2021 07:17:21 G11T
' 13. 2021-11-17 07:17:21
' 14. 07:17
' 15. 07:17:21
' 16. 7:17
' 17. 07:17 AM
' 18. 7:17 AM
'

 



answered Nov 17, 2021 by avibootz

Related questions

1 answer 150 views
1 answer 168 views
1 answer 177 views
1 answer 162 views
1 answer 159 views
1 answer 147 views
...