Sunday, May 19, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
173
rated 0 times [  175] [ 2]  / answers: 1 / hits: 7847  / 11 Years ago, mon, january 20, 2014, 12:00:00

How do I covert JavaScript string 5:00 PM to DateTime or TimeSpan when it get send to the MVC controller. I am using




bootstrap-timepicker




 // usage      
<script type=text/javascript>
$('#timepicker1').timepicker();
</script>


Javascript payload



{
Skip: 0
Status: []
Take: 15
DueTime: 1:00 PM // keep in mind that this is a string
}


Server Object would be something like



class TimeSheet
{
public TimeSpan DueTime;
}

More From » c#

 Answers
3

Use DateTime.Parse. Convert on server(on controller) when your string would transmit with your time.
http://msdn.microsoft.com/ru-ru/library/system.datetime.parse(v=vs.110).aspx


[#48517] Monday, January 20, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antonb

Total Points: 424
Total Questions: 104
Total Answers: 101

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;