How do I get the AM/PM value from a DateTime?

后端 未结 14 1641
刺人心
刺人心 2020-11-28 06:23

The code in question is below:

public static string ChangePersianDate(DateTime dateTime)
{
    System.Globalization.GregorianCalendar PC = new System.Globa         


        
14条回答
  •  时光说笑
    2020-11-28 06:55

    If you want to add time to LongDateString Date, you can format it this way:

        DateTime date = DateTime.Now;
        string formattedDate = date.ToLongDateString(); 
        string formattedTime = date.ToShortTimeString();
        Label1.Text = "New Formatted Date: " + formattedDate + " " + formattedTime;
    

    Output:

    New Formatted Date: Monday, January 1, 1900 8:53 PM 
    

提交回复
热议问题