By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

how to convert date time format as yyyyddmm hh:mm:ss in c#?

nirmalsingh
100+
P: 218
i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database.
Help me with sample coding plz..
Jan 5 '07 #1
Share this Question
Share on Google+
5 Replies


kenobewan
Expert 2.5K+
P: 4,871
Try placing your date in a string and then form it:
Expand|Select|Wrap|Line Numbers
  1. myDate.ToString("yyyy-MM-dd hh:mm:ss")
OR
Expand|Select|Wrap|Line Numbers
  1. myDate.DateFormat = "yyyy-MM-dd hh:mm:ss";
Hope that this helps.
Jan 5 '07 #2

Jimmy611
P: 52
DateTime.Now.ToString("yyyy/MM/dd HH:MM")
Jan 5 '07 #3

radcaesar
Expert 100+
P: 759
Try with,

DateTime.CustomFormat()

:)
Jan 5 '07 #4

nirmalsingh
100+
P: 218
its rarely working well with
myDate.ToString("yyyy-MM-dd hh:mm:ss")
but i have an error often as internal server error
Jan 5 '07 #5

kenobewan
Expert 2.5K+
P: 4,871
May be unrelated:
500 Internal Server Error Resolution

But suggest you post code in case. Does error give you a line number?
Jan 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.