erme Posted May 1, 2013 Share Posted May 1, 2013 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... Link to comment https://forums.phpfreaks.com/topic/277494-publishing-in-the-future/ Share on other sites More sharing options...
Jessica Posted May 1, 2013 Share Posted May 1, 2013 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 https://forums.phpfreaks.com/topic/277494-publishing-in-the-future/#findComment-1427507 Share on other sites More sharing options...
erme Posted May 1, 2013 Author Share Posted May 1, 2013 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 https://forums.phpfreaks.com/topic/277494-publishing-in-the-future/#findComment-1427516 Share on other sites More sharing options...
erme Posted May 1, 2013 Author Share Posted May 1, 2013 Just worked it out. 2008-11-11 12:45:34 Link to comment https://forums.phpfreaks.com/topic/277494-publishing-in-the-future/#findComment-1427522 Share on other sites More sharing options...
Jessica Posted May 1, 2013 Share Posted May 1, 2013 The field should be a DATETIME type Link to comment https://forums.phpfreaks.com/topic/277494-publishing-in-the-future/#findComment-1427525 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.