-2

I am trying to insert a date from a PHP page into WordPress field using the below code

//calculate new expiration date add 1 year +3 days

$date12 = new DateTime($date9);
$date12->modify('+368 day');
$new_expire= (string)$date12->format('m/d/Y');

$sql_renew = "update wp_usermeta set meta_value=".$new_expire." where user_id=".$user_value." AND meta_key='wpcf-expiration-date'";
$result_renew = $mysqli->query($sql_renew);

the output I got is: 0.000247157686604053

I want to insert it into readable format.

raiya
  • 15
  • 5

1 Answers1

0

I always suggest using strtotime with date manipulations. So maybe try this code and see if it is what you are looking for:

$date12 =  strtotime($date9 . '+ 368 days');
$new_expire = date('m/d/Y', $date12);

$sql_renew = "update wp_usermeta set meta_value=".$new_expire." where user_id=".$user_value." AND meta_key='wpcf-expiration-date'";
$result_renew = $mysqli->query($sql_renew_message);
John
  • 5,132
  • 1
  • 6
  • 17
  • I have tried but still the same output. And even I have tried to add a date as constant value ex, '01-02-2022' after the insert it shows 0.000494559841740850 – raiya Jan 06 '22 at 05:25
  • Even the timestamp of this date 01-02-2022 is 1643704324, not 0.000494559841740850 – raiya Jan 06 '22 at 08:29