更新时间:2023-11-05 12:26:52
以格式字符串编写的内容将从日期中提取.System.DateTime.Now.ToString(" ); System.DateTime.Now.ToString(" ); System.DateTime.Now.ToString(" );
尝试如下:DateTime myDateTime = DateTime.Now; string month = myDateTime.Month.ToString(); string year = myDateTime.Year.ToString();
使用此字符串 myDate = System.DateTime.Now.ToString(" MM yy");
my string for getting DateTime
is like this:
string myDate = System.DateTime.Now.ToString("MM/dd/yyyy");
If I want to obtain all values of dates of month, how can I exclude the day from above string.
Please help with the code.
With regards,
bishnu
whatever you will write in format string will be extracted from the date like.System.DateTime.Now.ToString("MM yy"); System.DateTime.Now.ToString("MMM yyyy"); System.DateTime.Now.ToString("MM/yyyy");
try as follows:DateTime myDateTime = DateTime.Now; string month = myDateTime.Month.ToString(); string year = myDateTime.Year.ToString();
use thisstring myDate = System.DateTime.Now.ToString("MM yy");