1

guys i have an issue with Datepicker in my input box, labelled "Order Date". Here is my input field : my input field with labelled "Order Date"

When my form is submitted with a blank date field, it automatically get sets to 01-01-1970.

Like this : After submitting the form with a blank field

So, here what i want is when i submitted my form with a blank field it should be set to blank rather than 01-01-1970. Any help would be appreciated. Thank you.

vitally
  • 377
  • 6
  • 17
  • 1
    check this post http://stackoverflow.com/questions/7978787/jquery-ui-datepicker-take-value-1970-if-input-field-is-blank – tzafar May 21 '15 at 05:53
  • try to set `defaultDate: ''` in datepicker options or remove it – tzafar May 21 '15 at 05:56
  • nothing get done automatically, there must be some code which is setting this value. – Taimur Khan May 21 '15 at 06:14
  • I believe you are using php and somewhere using strtotime function. Please see the following explanation http://stackoverflow.com/questions/8984595/php-date-showing-1970-01-01-after-conversion – Taimur Khan May 21 '15 at 06:18
  • @Taimur Khan yes bro, you are right. i am using a strtotime function something like this : $_POST['bOrderDate'] = date('Y-m-d', strtotime( $_POST['bOrderDate'] ) ); – vitally May 21 '15 at 06:22
  • @TaimurKhan but i already replace the / with - – vitally May 21 '15 at 06:23
  • @TaimurKhan but i am converting the date for my datepicker format "d-m-Y" to "Y-m-d" after submission of my form – vitally May 21 '15 at 06:28
  • Are you taking care of blank or empty value? if there is empty value in order date field you will get 01-01-1970 from strtotime function – Taimur Khan May 21 '15 at 06:35
  • @TaimurKhan yes.inside that input box i checked it's value like this value="" – vitally May 21 '15 at 06:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78380/discussion-between-taimur-khan-and-vitally). – Taimur Khan May 21 '15 at 06:43

1 Answers1

3

Please change !empty($_POST['bOrderDate']) as follows !empty(trim($_POST['bOrderDate'])) that will solve the issue.

Taimur Khan
  • 531
  • 8
  • 21