This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » PHP » Help with date format
Reply

Help with date format

lucas loma
Member



Since: 14 Dec 2009
Posts: 1
Posted 14 Dec 2009 13:42:43

Hi, I have a record update form that shows Start date and End date in 2 separate fields like dd/mm/yyyy. When I edit the dates they do not get to the database correctly, all I get is 0000/00/00. I guess this is because the date format accepted by MySQL is yyyy/mm/dd.

I'm stuck because I don't know how to convert the dates back to MySQL format for updating.

This is the code that displays the start date:

<input name="AG_fechai" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_eventosUpdate_RS['AG_fechai'])); ?>" size="32" />

This is the code that displays the end date:

<input name="AG_fechaf" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_eventosUpdate_RS['AG_fechaf'])); ?>" size="32" />

This is my update query.(AG_fechai and AG_fechaf are the start and end date fields) which are not been updated. I appreciate your help. Thanks.

// $updateSQL = sprintf("UPDATE t_agenda SET AG_fechai=%s, AG_fechaf=%s, AG_precio=%s, AG_horario=%s, AG_titulo_esp=%s, AG_titulo_eng=%s, AG_titulo_ger=%s, AG_titulo_fra=%s WHERE id_AG=%s",
GetSQLValueString($_POST['AG_fechai'], "date",
GetSQLValueString($_POST['AG_fechaf'], "date",
GetSQLValueString($_POST['AG_precio'], "text",
GetSQLValueString($_POST['AG_horario'], "text",
GetSQLValueString($_POST['AG_titulo_esp'], "text",
GetSQLValueString($_POST['AG_titulo_eng'], "text",
GetSQLValueString($_POST['AG_titulo_ger'], "text",
GetSQLValueString($_POST['AG_titulo_fra'], "text",
GetSQLValueString($_POST['id_AG'], "int");

mysql_select_db($database_amat_connect, $amat_connect);
$Result1 = mysql_query($updateSQL, $amat_connect) or die(mysql_error());

Hi, I have a record update form that shows Start date and End date in 2 separate fields like dd/mm/yyyy. When I edit the dates they do not get to the database correctly, all I get is 0000/00/00. I guess this is because the date format accepted by MySQL is yyyy/mm/dd.

I'm stuck because I don't know how to convert the dates back to MySQL format for updating.

This is the code that displays the start date:

<input name="AG_fechai" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_eventosUpdate_RS['AG_fechai'])); ?>" size="32" />

This is the code that displays the end date:

<input name="AG_fechaf" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_eventosUpdate_RS['AG_fechaf'])); ?>" size="32" />

This is my update query.(AG_fechai and AG_fechaf are the start and end date fields) which are not been updated. I appreciate your help. Thanks.

// $updateSQL = sprintf("UPDATE t_agenda SET AG_fechai=%s, AG_fechaf=%s, AG_precio=%s, AG_horario=%s, AG_titulo_esp=%s, AG_titulo_eng=%s, AG_titulo_ger=%s, AG_titulo_fra=%s WHERE id_AG=%s",
GetSQLValueString($_POST['AG_fechai'], "date",
GetSQLValueString($_POST['AG_fechaf'], "date",
GetSQLValueString($_POST['AG_precio'], "text",
GetSQLValueString($_POST['AG_horario'], "text",
GetSQLValueString($_POST['AG_titulo_esp'], "text",
GetSQLValueString($_POST['AG_titulo_eng'], "text",
GetSQLValueString($_POST['AG_titulo_ger'], "text",
GetSQLValueString($_POST['AG_titulo_fra'], "text",
GetSQLValueString($_POST['id_AG'], "int");

mysql_select_db($database_amat_connect, $amat_connect);
$Result1 = mysql_query($updateSQL, $amat_connect) or die(mysql_error());
stephen park
Member



Since: 12 Apr 2001
Posts: 6
Replied 05 Mar 2010 13:45:17
try changing the code 'd/m/Y' to 'Y/m/d' this may change the order and allow your database to update...

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency