.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> DateTime >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Some date and time format in c#.net

Posted By:laptop charles       Posted Date: May 19, 2011    Points: 40    Category: DateTime    URL: http://www.dotnetspark.com  

I have shared about some date and time format in C#.net
 

Following code is some date and time format in C#.net

using System;
using System.Collections.Generic;



namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dateTime = DateTime.Now;
            Console.WriteLine(dateTime.ToString("dddd dd yyyy"));
            Console.WriteLine(dateTime.ToString("ddd dd yyyy"));
            Console.WriteLine(dateTime.ToString("HH:mm:ss"));
            Console.WriteLine(dateTime.ToString("hh:mm"));
            Console.WriteLine(dateTime.ToString("mm/dd/yyyy HH:mm"));
            Console.WriteLine(dateTime.ToString("dd/yyyy"));
            Console.WriteLine(dateTime.Year);
            Console.WriteLine(dateTime.Date);
            Console.WriteLine(dateTime.DayOfWeek);
            Console.WriteLine(dateTime.DayOfYear);
            Console.WriteLine(dateTime.Day);            
         
            Console.ReadLine();
        }
    }
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend