Jump to content

Publishing in the future


erme
Go to solution Solved by Jessica,

Recommended Posts

Hi, I've created a CMS that enables the user to publish an article which will appear on the site immediately. I need to add in the option to schedule displaying the article.

 

I have a field in the MySQL table for pubished_date. How can I write something in PHP that won't display articles where published_date is in the future / hasn't arrived yet?

 

I could then maybe set up a cron job to run the script every night.

 

Thanks in advance...

Edited by erme
Link to comment
Share on other sites

  • Solution

Store them as normal. Your script that displays posts, should only query for posts where the published date is in the past.

 

SELECT * FROM posts WHERE published_date <= NOW()

 

etc.

Link to comment
Share on other sites

Store them as normal. Your script that displays posts, should only query for posts where the published date is in the past.

 

SELECT * FROM posts WHERE published_date <= NOW()

 

etc.

 

Thanks for your reply. What format will the date and time need to be stored as for this to work? Currently it is stored like this 2013043014:14:35

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.