anth0ny Posted January 6, 2009 Share Posted January 6, 2009 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 More sharing options...
anth0ny Posted January 6, 2009 Author Share Posted January 6, 2009 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 More sharing options...
anth0ny Posted January 6, 2009 Author Share Posted January 6, 2009 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 Link to comment https://forums.phpfreaks.com/topic/139672-date/#findComment-730769 Share on other sites More sharing options...
sniperscope Posted January 6, 2009 Share Posted January 6, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.