I am using jQueryUI datepicker and here is the code.
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function() { $( "#from" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 3, onClose: function( selectedDate ) { $( "#to" ).datepicker( "option", "minDate", selectedDate ); } }); $( "#to" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 3, onClose: function( selectedDate ) { $( "#from" ).datepicker( "option", "maxDate", selectedDate ); } }); }); </script> <form action="{LINKTO_EXPORT}" method="post"> <h1>{EXPORT_CSV}</h1> <label for="from">from</label> <input type="text" id="from" name="from"> <label for="to">to</label> <input type="text" id="to" name="to"> <input type="submit" value="{EXPORT_TEXT}"> </form>
When I send from and to,
$fromstr = $_POST["from"]; $tostr = $_POST["to"]; $from = date('Ymd H:i:s',strtotime($fromstr." 02:00:00")); $to = date('Ymd H:i:s',strtotime($tostr." 02:00:00"));
to was converted correctly, i.e. 2015-06-13 02:00:00 , but from does not have. Instead, he returned on 6/1/2015 2:00 . To make sure that I get the correct values, I repeated the $fromstr and $tostr .
$fromstr returned 6/1/2015 $tostr returned 06/13/2015
Why did m / d / yyyy return from , and to do mm / dd / yyyy? How to convert m / d / yyyy string to timestamp? Please help, thanks!
source share