Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

DateTime.ToLongDateString() Method in C#

  • Last Updated : 11 Feb, 2019

This method is used to convert the value of the current DateTime object to its equivalent long date string representation.

Syntax: public string ToLongDateString ();

Return Value: This method returns a string that contains the long date string representation of the current DateTime object.

Below programs illustrate the use of DateTime.ToLongDateString() Method:

Example 1:




// C# program to demonstrate the
// DateTime.ToLongDateString()
// Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // creating object of DateTime
        DateTime date = new DateTime(2011, 1,
                                1, 4, 0, 15);
  
        // Converting the value of the 
        // current DateTime object to 
        // its equivalent long date 
        // string representation.
        // using ToLongDateString() method;
        string value = date.ToLongDateString();
  
        // Display the date
        Console.WriteLine("String representation"+
                        " of date is {0}", value);
    }
}
Output:
String representation of date is Saturday, 01 January 2011

Example 2:




// C# program to demonstrate the
// DateTime.ToLongDateString()
// Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // creating object of DateTime
        DateTime date = DateTime.Now;
  
        // Converting the value of the
        // current DateTime object to 
        // its equivalent long date 
        // string representation.
        // using ToLongDateString() method;
        string value = date.ToLongDateString();
  
        // Display the date
        Console.WriteLine("String representation "+
                          "of date is {0}", value);
    }
}
Output:
String representation of date is Monday, 11 February 2019

Reference:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!