Jump to content

date


anth0ny

Recommended Posts

Hi how do i insert a date with php into mysql.

 

I can do it in the us format, but i need to do it in the uk format d-m-Y. In the input text box (this uses a calander) it needs to show as d-m-Y before the form gets posted.

 

I know that it cant be entered into mysql as d-m-Y. But there must be a way of displaying it and then swithching it once its posted?

Link to comment
https://forums.phpfreaks.com/topic/139672-date/
Share on other sites

this is the code that i'm using:

 

$departureDate = date("Y-m-d", strtotime($_POST['departureDate']));

 

<input name="departureDate" type="text" class="fields" id="departureDateField" value="<?php if(isset($_POST['departureDate'])) echo $_POST['departureDate']; ?>" onfocus="this.select();lcs(this)" onclick="event.cancelBubble=true;this.select();lcs(this)">

Link to comment
https://forums.phpfreaks.com/topic/139672-date/#findComment-730766
Share on other sites

and this is the code i use to display the date in uk format

 

<?php echo date('d/m/Y',strtotime($departureDate));?>

 

I just need a way to make it show in this format on the form

 

Why don't you remove Strtotime(). Simply

<?php echo date('d/m/Y'); ?>

should give you 00/00/0000 format.

Link to comment
https://forums.phpfreaks.com/topic/139672-date/#findComment-730963
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.