WordPress.org

Ready to get started?Download WordPress

Forums

Content Scheduler
[resolved] Pull the the expiration date (5 posts)

  1. ElDroid
    Member
    Posted 1 year ago #

    Is there any way to pull the expiration date?
    Specifically I want to pull the remaining days to expiration.

    Thanks in advance.

    Ruben

    http://wordpress.org/extend/plugins/content-scheduler/

  2. ElDroid
    Member
    Posted 1 year ago #

    Sorry I just read the PDF doc. Thanks fot this awesome plugin!

  3. Permarad
    Member
    Posted 1 year ago #

    Just for reference, to pretty up the date being pulled from the database you can use this code to get something like this. eg 10 Days 20 Hrs Remain.

    global $wp_query;
    		$postid = $wp_query->post->ID;
    
    		//Convert to date
    		$datestr=get_post_meta($postid, '_cs-expire-date', true);//Your date
    		$date=strtotime($datestr);//Converted to a PHP date (a second count)
    
    		//Calculate difference
    		$diff=$date-time();//time returns current time in seconds
    		$days=floor($diff/(60*60*24));//seconds/minute*minutes/hour*hours/day)
    		$hours=round(($diff-$days*60*60*24)/(60*60));
    
    		//Report
    		echo "$days Days $hours Hrs Remain<br />";
  4. dgitaly
    Member
    Posted 1 year ago #

    @ Permarad - Thank you for the above code. Great suggestion!

  5. Paul Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    Nice!
    That reminds me, I need to update the docs... I guess they're mostly still valid, though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.