2

how to change the date time format 2011-09-01 09:39:23 to 2011-Aug-01 09:39:23 in asp.net

I am using this DateTime.Now; to get the date time but I want it in 2011-Aug-01 09:39:23 format, how to do that

I set datetime as string now = DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss");

both did not work

 param[1] = new MySqlParameter("@Created", MySqlDbType.DateTime);
        param[1].Value = now;
        command.Parameters.AddWithValue("@Created", now);
        param[2] = new MySqlParameter("@Modified", MySqlDbType.DateTime);
        param[2].Value = DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss"); 
        command.Parameters.AddWithValue("@Modified", DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss"));

3 Answers 3

4

You will find This article useful

More specifically, you want:

yourDate.toString("yyyy-MMM-dd hh:mm:ss");
Sign up to request clarification or add additional context in comments.

Comments

2

DateTime.Now.ToString("yyyy-MMM-dd hh:mm:ss");

Comments

2
if (IsPostBack)
{
    txtrcptdate.Text = DateTime.Now.ToString("dd/MMM/yyyy hh:mm:ss ");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.