Welcome Guest, Not a member yet? Register   Sign In
How to tell if a Blog Post is 'New'
#1

[eluser]Gwarrior[/eluser]
Can someone break down how I decide if a blog post is new (say if it's a day or less old).

Can't find any guides anywhere. Thanks!
#2

[eluser]umefarooq[/eluser]
Hi
there are two ways you can check if you have post date column in your table, till how many days you want to keep it new post just make calculation with post date.
#3

[eluser]Gwarrior[/eluser]
Thanks for the quick reply!

So you're saying make a 'post_date' column (which I have), but how do I subtract times?

Or can you even subtract time?
#4

[eluser]Ben Edmunds[/eluser]
Oh yea, you can subtract time. Look up the PHP mktime() function.
#5

[eluser]saidai jagan[/eluser]
You may use the query like this
using the blog id,
Code:
SELECT * FROM blogs ORDER BY blog_id DESC LIMIT 0,1 ;
By date,
Code:
SELECT blog_id FROM blogs WHERE blog_date = CURDATE();
#6

[eluser]Ben Edmunds[/eluser]
The problem with doing it that way is that usually you would want the last 24 hrs, not todays date because at 12:01am you are only looking at 1 min...

It's all about what you need though.
#7

[eluser]Gwarrior[/eluser]
Very helpful. Thanks fellas.
#8

[eluser]Zeeshan Rasool[/eluser]
[quote author="Gwarrior" date="1258022139"]Can someone break down how I decide if a blog post is new (say if it's a day or less old).

Can't find any guides anywhere. Thanks![/quote]
As Ben said, he is right in that case but you may use some thing like that:
Let say, You want to keep your latest posts some where , so you can use
Code:
YourDate >= DATE_SUB(CURDATE(), INTERVAL 1 DAY)
How ever if you are showing all posts and you need to just pin point those posts who are new then you have to put a check that will find those posts.

Hope you got it ! Confusedmirk:




Theme © iAndrew 2016 - Forum software by © MyBB