0

In mysql table date is stored in yyyy-mm-dd hh:mm:ss format

I want to show on php form in format of dd/mm/yyyy input field type date

I tried following code ... not working

$pddt = date_format( date_create($row['invdt']), 'd/m/Y' );

1 Answer 1

1

You have to use date() function with PHP strtotime() function.

$pddt = date("d/m/Y",strtotime($row['invdt']));  
Sign up to request clarification or add additional context in comments.

2 Comments

still not working for code <td align="left"><input type="date" maxlength="10" size="10" name="txtddt" value="<?php echo $pddt; ?>"/>, but worked for code <td align="left"><input type="text" maxlength="10" size="10" name="txtddt" value="<?php echo $pddt; ?>"/> .. I want to get proper date, if invalid message
Where it is not working? Put your code in question where date is not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.