Get the system date and split day, month and year

后端 未结 5 931
猫巷女王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 18:57

    You can split date month year from current date as follows:

    DateTime todaysDate = DateTime.Now.Date;

    Day:

    int day = todaysDate.Day;

    Month:

    int month = todaysDate.Month;

    Year:

    int year = todaysDate.Year;

提交回复
热议问题