Convert Date to “dd-MMM-yyyy” format c#

后端 未结 5 1371
名媛妹妹
名媛妹妹 2021-01-17 09:15

Guys i am unable to convert datetime to \"dd-MMM-yyyy\" format. My code is given below:

TreeNode tn = new TreeNode(dr[\"pBillDate\"].ToString());       // He         


        
相关标签:
5条回答
  • 2021-01-17 09:55

    Try this code:

    string formattedDate = YourDate.ToString("dd MMM yyyy");
    

    It will format to like:

    12 Nov 2012
    
    0 讨论(0)
  • 2021-01-17 09:58

    Find below code:

    DateTime todayDay = DateTime.Today.ToString();

    It will provide you with dd-MMM-yyyy format.

    0 讨论(0)
  • 2021-01-17 10:15

    try Following

        TreeNode tn = new TreeNode(dr["pBillDate"].ToShortDateString()); 
    

    it can convert DateTime to Date

    Thanks,

    0 讨论(0)
  • 2021-01-17 10:16
    DateTime StartDate = Convert.ToDateTime(datepicker.Text);
    string Date = StartDate.ToString("dd-MMM-yyyy");
    
    0 讨论(0)
  • 2021-01-17 10:19

    The following couple examples should work:

    DateTime dt = Convert.ToDateTime(dr["pBillDate"]);
    
    TreeNode tn = new TreeNode(String.Format("{0:dd-MMM-yyyy}", dt));
    

    or

    DateTime dt = Convert.ToDateTime(dr["pBillDate"]);
    
    TreeNode tn = new TreeNode(dt.ToString("dd-MMM-yyyy"));
    
    0 讨论(0)
提交回复
热议问题