Store Date Time in database


Using a “onChange” event of a drop down {active} i’m trying to store the Date and Time in mySQL table but it only seems to take the date?

The field in SC is set to Date-Time and so is the field in mySQL table.

This code is setting the fields in SC but the field wont show the time only the date (ex. 2014-09-19 00:00:00) ?

When i do a quick echo of {date_activated} I get the right response (2014-09-19 16:39:17) but it won’t update the field in SC or the database?

Any help is appreciated.

if ({active} == “1”)
{date_activated} = date(“Y-m-d H:i:s”); //Activated Date
{date_deactivated} = “”;
elseif ({active} == “0”)
{date_deactivated} = date(“Y-m-d H:i:s”);
//Do nothing

There are a lot of possible causes. But in this case it looks to me that you are making a basic error, but a logical one. I have had this one too. The main problem is that the field you are refering to is a datefield in scriptcase? Then you are moving a date string into a field with another internal format. Look at the field properties. There’s a difference in the displaying format and the internal format. Next sample will add a day to an editable date field. The presentation is dd-mm-yyyy (european) but internal yyyymmdd:

{startdate}=date(‘Ymd’, strtotime({startdate}."+1 days"));