How to get the current date without the time?

后端 未结 12 1630
青春惊慌失措
青春惊慌失措 2020-11-29 00:50

I am able to get date and time using:

DateTime now = DateTime.Now;

How can I get the current date and time separately in the DateTime forma

12条回答
  •  粉色の甜心
    2020-11-29 01:18

    for month

    DateTime.Now.ToString("MM");
    

    for day

    DateTime.Now.ToString("dd");
    

    for year

    DateTime.Now.ToString("yyyy");
    

提交回复
热议问题