Custom Field Date Problem
-
I’m making some modifications to a custom theme, and trying to do something that should be simple, but there’s something I must be missing.
I’ve created a custom field in a form called e_date, which is a date entered as text. The custom field seems to work correctly and shows up in the custom fields section of the admin as the correct date.
There’s also an existing function that expires posts and deletes them after XXX days. It works correctly as is, but I need it to do something slightly different. The original code looked like:
$ad_length = get_option("prun_period"); $expires = date('m/d/Y G:i:s', strtotime("+" . $ad_length . " days"));
I’m trying to modify this so they’re deleted 1 day after e_date. I’ve tried a number of things but everyhting I try spits out some nonsense date as $expires. The dates should look something like 08/14/2009 for e_date and 08/15/2009 for $expires. Instead $expires is coming back with dates like 01/01/1970 or 12/31/1969.
Here are some of the things I’ve tried (along with numerous variations of each.
expires = date('m/d/Y', mktime(date('m',$e_date),date('d',$e_date)+1 days,date('Y',$e_date)));
and
$expires = date('m/d/Y',strtotime('+1 days',e_date));
Any idea what the problem is? Any help with the code?
- The topic ‘Custom Field Date Problem’ is closed to new replies.