The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Date format issue while fetching data
shankar from vizag
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
CharlesEF
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic
shankar from vizag   Date format issue while fetching data   May 14 2019, 09:33 AM
CharlesEF   Ok, I'm back. Yesterday was a long day, glad ...   May 14 2019, 11:10 AM
shankar from vizag   Ok, I'm back. Yesterday was a long day, glad...   May 15 2019, 08:11 PM
CharlesEF   The jQuery site provides a working example, found ...   May 16 2019, 12:32 AM
shankar from vizag   The jQuery site provides a working example, found...   May 17 2019, 09:28 AM
CharlesEF   Are you getting the date in the correct format? I...   May 17 2019, 09:49 AM
CharlesEF   Is your database column a DATE or DATETIME? If it...   May 17 2019, 12:00 PM
CharlesEF   Since I've not heard back from you I'm not...   May 18 2019, 01:09 PM
shankar from vizag   Since I've not heard back from you I'm no...   May 20 2019, 10:32 AM
CharlesEF   It seems MySQL supports ISO-8601 date/time values,...   May 20 2019, 11:26 AM
shankar from vizag   It seems MySQL supports ISO-8601 date/time values...   May 21 2019, 02:23 AM
shankar from vizag   It seems MySQL supports ISO-8601 date/time values...   May 21 2019, 09:43 AM
CharlesEF   Before I pick this code apart, please post the PHP...   May 21 2019, 10:26 AM
CharlesEF   I did a little research and found that date_format...   May 21 2019, 07:12 PM
shankar from vizag   I did a little research and found that date_forma...   May 22 2019, 09:10 AM
CharlesEF   Glad you got it working. Before I read about DATE...   May 22 2019, 02:41 PM
CharlesEF   FYI, as a test I put together a MySQL database tab...   May 22 2019, 06:44 PM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th April 2024 - 12:01 PM