how to get current month and year

前端 未结 8 679
南方客
南方客 2020-12-25 09:39

Can anybody tell me that how I can get current month and year and show it in a label in ASP.NET?

8条回答
  •  旧巷少年郎
    2020-12-25 10:15

    If you have following two labels:

    
    
    

    Than you can use following code just need to set the Text Property for these labels like:

    MonthLabel.Text = DateTime.Now.Month.ToString();
    YearLabel.Text = DateTime.Now.Year.ToString();
    

提交回复
热议问题