Click here to Skip to main content
15,900,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1- if i want to make get just time without Date from user as 10:30 Pm not 1/1/2015 00:00:00
2- if I Want get time of Start or End Process and search about time Between that two times

if time of start 10:00 am --- time of End 02:00 pm

user will search enter 01:00 pm that between start & end
Posted
Comments
PIEBALDconsult 19-Feb-15 15:30pm    
datetime.TimeOfDay.ToString() ?

1 solution

First get the text from the textbox and try to parse it into a DateTime format.
Then get the time of day as a string.

C#
string date = string.Empty;

if (!string.IsNullOrWhiteSpace(textBox1.Text)) {
    DateTime timeDate = new DateTime(); 
    
    if (DateTime.TryParse(textBox1.Text, out timeDate)) {
        date = timeDate.TimeOfDay.ToString();
    }
}

if (!string.IsNullOrWhiteSpace(date)) {
    // do what is needed
}
 
Share this answer
 

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