Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is the code which i use to convert date time format

DateTime dt1 = Convert.ToDateTime(starttimefirst);// in starttimefirst format will be in yyyy-MM-dd
string Newdt1 = dt1.ToString("yyyy/MM/dd HH:mm:ss");

but in newdt1 i am not getting yyyy/MM/dd i am getting yyyy-MM-dd format only

so kindly help me regarding this. Thankyou.
Posted
Comments
Mike Meinz 9-Dec-13 7:47am    
It works correctly for me. Are you posting all of the pertinent code?

http://www.asp.net/ajaxlibrary/ajaxcontroltoolkitsamplesite/calendar/calendar.aspx[^]

Change the format property of Calendar Extender control

VB
<ajaxToolkit:Calendar runat="server"
    TargetControlID="Date1"
    CssClass="ClassName"
    Format="MMMM d, yyyy"
    PopupButtonID="Image1" />



eg
Format"MMMM d, yyyy"
Format="dd.MM.yyyy"
Format="yyyy/MM/dd"
 
Share this answer
 
Try

DateTime.ParseExact(inputdate, "yyyy-MM-dd", CultureInfo.InvarientCulture).ToString("yyyy/MM/dd HH:mm:ss")


Or

Convert.ToDateTime(dt1 , CultureInfo.CurrentCulture).ToString("yyyy/MM/dd HH:mm:ss");
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900