date format

Alles, was PHP betrifft, kann hier besprochen werden.

date format

Postby pkimran » 14. April 2015 14:22

hy
i am new in php. the problem is....
mysql date formate is yyyy-mm-dd and in php form date field format shows mm-dd-yyyy (with calander)
i just want php form field should also show date format as yyyy-mm-dd
the date field in php form is as below


<td ><b>Date</b></td>
<td><input type=\"date\"name=\"Date\\"></td></tr>

in mysql the type of filed "date" is date.
pkimran
 
Posts: 10
Joined: 03. April 2015 14:21
Operating System: windows 7

Re: date format

Postby Altrea » 14. April 2015 16:07

Hi,

pkimran wrote:i just want php form field should also show date format as yyyy-mm-dd

You are wrong, that is not PHP. That is HTML5 and this works just in your browser.
So your issue is a browser issue. And your browser will display the date field location dependend (my browser shows d.m.Y).

Have you ever tried to send your form and see what data the field contains?

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: date format

Postby pkimran » 17. April 2015 10:58

thanks alot Altrea
i change my local system date format to dd-mm-yyyy its work and now in index.php date column calender shows dd-mm-yyyy.
but after submitt save the date as yyyy-mm-dd :(
actually i want to search data between two dates all code is ok but result is "no record found"
i assume that there is date format problem may be.
can you help me to search between two dates?
pkimran
 
Posts: 10
Joined: 03. April 2015 14:21
Operating System: windows 7

Re: date format

Postby Altrea » 17. April 2015 11:38

pkimran wrote:but after submitt save the date as yyyy-mm-dd :(

That is not :(, that is =D
That is the magic of the browsers interpretation of the HTML5 date field. Independend which location your User used, your script aleays get the same date format to work with.
MySQLs date type uses the same format.

pkimran wrote:can you help me to search between two dates?

No, because i don't know anything about your data and code.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to PHP

Who is online

Users browsing this forum: No registered users and 9 guests