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 22 2019, 06:44 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



FYI, as a test I put together a MySQL database table and inserted date data. The dates are stored in 'YYYY-MM-DD' format. I used this line of code (modified a little)
CODE
$q = "SELECT `file_no`, DATE_FORMAT(`sent_on`,'%d-%m-%Y') FROM `filetrack` WHERE `sent_on` BETWEEN CAST('$frmdate' AS DATE) AND CAST('$todate' AS DATE) ORDER BY `sent_on`";
and it worked correctly. I learned from this exchange also, which is why help forums exist.
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
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:14 AM