Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current date in 'YYYY-MM-DD' format in ASP.NET?

How to get current date in 'YYYY-MM-DD' format in ASP.NET ?

like image 362
Parth Bhatt Avatar asked Feb 17 '11 13:02

Parth Bhatt


People also ask

How can set current date in asp net?

Client Side Method to display Current Date and Time The ShowCurrentTime method makes an AJAX call to the server using ASP.Net AJAX ScriptManager PageMethods and executes the GetCurrentTime method which accepts the username and returns a string value.

How to Convert string to date format in ASP net c#?

DateTime dt2 = DateTime. ParseExact(date31strin, "MM-dd-yyyy HH:mm:ss", CultureInfo. InvariantCulture); the format is changed to "dd-MM-yyyy HH:mm:ss" .

How to set date format in DateTime c#?

It should be formatted like this: myDateTime. ToString("yyyy/MM/dd hh:mm:ss"); or myDateTime. ToString("yyyy/MM/dd); Because mm is for minute and for month MM should be used.


1 Answers

Which WebControl are you using? Did you try?

DateTime.Now.ToString("yyyy-MM-dd"); 
like image 96
goenning Avatar answered Sep 20 '22 14:09

goenning