Get the system date and split day, month and year

后端 未结 5 934
猫巷女王i
猫巷女王i 2020-12-06 18:18

My system date format is dd-MM-yyyy(20-10-2012) and I\'m getting the date and using separator to split the date, month and year. I need to convert date format (dd/MM/yyyy) w

5条回答
  •  日久生厌
    2020-12-06 19:10

    Here is what you are looking for:

    String sDate = DateTime.Now.ToString();
    DateTime datevalue = (Convert.ToDateTime(sDate.ToString()));
    
    String dy = datevalue.Day.ToString();
    String mn = datevalue.Month.ToString();
    String yy = datevalue.Year.ToString();
    

    OR

    Alternatively, you can use split function to split string date into day, month and year here.

    Hope, it will helps you... Cheers. !!

提交回复
热议问题