Jump to content

Date Field Defaults to 01/01/1970...!!?


Fearpig

Recommended Posts

Hello,

I'm having a problem with an SQL datetime field. The field is set to allow nulls and that it has no default value but when I submit the PHP form the datetime field gets updated to 01/01/1970 12:00:00:00 AM. Can anyone tell me whats going on!? I want to have the null values!

 

Thanks for your help!

Link to comment
https://forums.phpfreaks.com/topic/51843-date-field-defaults-to-01011970/
Share on other sites

Dates are set with a timestamp that is n seconds from a baseline date, in this case the one you see above. I suspect your query is setting the date with a null string when the date has no value. Instead try changing the query so that it is not setting the date at all or use NULL.

 

Post the code you use to build/run the query for more help.

Hi Guys,

Here's the code I use for the update, all of the variables are captured using $_POST['Field_Name'].

 

 

<?php
$sql_Insert="UPDATE tbl_Attendees SET Payment_Recieved='$date_PR_formatted',Payment_Method='$Payment_Method',Confirmation_Date='$date_CD_formatted',Training_Pack='$date_TP_formatted',Certificate_Date='$date_Cert_formatted' WHERE Person_ID='$Person_ID' AND Course_ID='$Course_ID'";
$Insert_Details=odbc_exec($conn,$sql_Insert);
if (!$Insert_Details)
{exit("Error in SQL");}
?>

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.