Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
regDate = Convert.ToDateTime(DateTime.Today.ToString()).ToString("yyyy/MM/dd hh:mm:ss");  

but here not getting time in proper format

/*2008-08-01 20:35:45 yyyy-MM-dd hh:mm:ss*/
Posted
Updated 22-Apr-12 22:31pm
v2

Hi,

Try this:

C#
string regDate = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");


all the best.
 
Share this answer
 
Comments
Reza Ahmadi 23-Apr-12 5:13am    
5!
You should be doing :
C#
string regDate = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");
 
Share this answer
 
Comments
[no name] 23-Apr-12 5:53am    
i have used it but inser in database like this "2012/04/23 12:00:00"
current time not getting
Mehdi Gholam 23-Apr-12 5:59am    
Check your column type in your sql table has time also.
[no name] 23-Apr-12 6:02am    
[Reg_Date][Varchar] (19) NULL,/*2008-08-01 20:35:45 yyyy-MM-dd hh:mm:ss*/
[no name] 23-Apr-12 6:06am    
Getting Thanks..

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