+ 1

How to change date storedin variable in 'dd/mm/yyyy' different format to yyyy/mm/ dd and store in mysql databases

change ddmmyyyy date format to yyyymmdd and store in different variable .. bootstrap date picker used. I want to store to database as yyyymmdd format start date = ddmmyyyy check-in date = start date in yyyymmdd format how to assign in PHP or js store in MySQL post method

20th Dec 2017, 6:00 PM
vinayagam D
vinayagam D - avatar
3 Réponses
+ 7
To store dates or times in MySQL use date, datetimeor timestamp. I'd recommend the first two for most purposes. To tell MySQL how to parse your date format use the STR_TO_DATE function. Here's an example: CREATE TABLE table1 (`Date` Date); INSERT INTO table1 (`Date`) VALUES (STR_TO_DATE('01/05/2010', '%m/%d/%Y')); SELECT * FROM table1; Date 2010-01-05 To format the results back into the original form look at the DATE_FORMATfunction. Note that you only need to format it if you want to display it as a string using something other than the default format. ↓↓↓ :) https://stackoverflow.com/questions/2869874/how-store-date-in-mysql-database
20th Dec 2017, 6:05 PM
James16
James16 - avatar
+ 1
MySQL stores 0000/00/00 values in tables instead of storing 22/12/2017 captured in HTML response enter in value of start date of form post syntax error will be there , rough demo to clarify questions answer create table room details( check-in date = echo _post ( start date); check-out date = echo _post( end date; insert values got in HTML response how to post how to get date in ddmmyyyy format to yyyymmdd format
20th Dec 2017, 6:23 PM
vinayagam D
vinayagam D - avatar
0
$date = date('Ymd'); put this variable to your database
20th Dec 2017, 8:39 PM
BodyaBuilder
BodyaBuilder - avatar