Date format issue while fetching data |
Date format issue while fetching data |
shankar from vizag |
May 14 2019, 09:33 AM
Post
#1
|
Advanced Member Group: Members Posts: 202 Joined: 18-June 13 Member No.: 19,316 |
Greetings
In my php page, I have used JQuery datepicker and it is working fine when the function as follows: <script> $("#myDatepicker").datepicker({dateFormat: 'yy-mm-dd'}); </script> But, I need the format as dd-mm-yy. When I tried to change the format as below, <script> $("#myDatepicker").datepicker({dateFormat: 'dd-mm-yy'}); </script> the date is saving in table as 0000-00-00. Kindly help me out to overcome this issue. regards |
CharlesEF |
May 17 2019, 12:00 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Is your database column a DATE or DATETIME? If it is a DATE then a string date will work. If it is a DATETIME then you need to convert the date string into a date, then write that to the database.
It is a good idea to store dates as 'YYYY-MM-DD' in the database. When you pull it out then you can convert it to whatever date format you wish to use. |
Lo-Fi Version | Time is now: 28th April 2024 - 12:01 PM |