I am trying to write a script that will calculate dates into a database depending on the value entered for `cdr_original_install_date`.

If if is blank I would like it to enter NULL for both `$cdr_install` and `$cdr_renew`.

If not I would like `$cdr_install` to be the date entered in `cdr_original_install_date`, `$cdr_renew` to be the same date plus one year. If the `$cdr_renew` date has not passed I would like it to change the value of $cdr\_support to 'Initial Warranty';

I have tried several ways to write this but the only bit that works is if no date is entered NULL is saved to the database. If I enter a date I either get dates entered as 1970-01-01 or an error saying that `strtotime()` expects parameter 2 to be long, string given which refers to the line adding one year to `$cdr_install`.

```
if($_POST['cdr_original_install_date'] == ''){
    $cdr_install = 'NULL';
    $cdr_renew = 'NULL';
} else {
    $cdr_install = date('Y-m-d', strtotime($_POST['cdr_original_install_date']));
    $cdr_renew = date('Y-m-d', strtotime($cdr_install,'+ 1 year'));
        if(strtotime($cdr_renew) > time()){
            $cdr_support = 'Initial Waranty';
        }
}

```

The database field are just date so the problem doesn't appear to be the formatting of the date value