Updated_at not today?

How can you verify that it has not been updated today?

if @post.updated_ad “is not today”
@post.counter = @post.counter + 1
@post.save
end

On 29 June 2014 13:41, Fresh M. [email protected] wrote:

How can you verify that it has not been updated today?

The first question is what do you mean by today? Note in particular
that your date may not be the same as mine if we are in different
timezones.

Colin

Check if the current date is equal to that?

–Rob
Sent from my phone…excuse any typos please!

Colin L. wrote in post #1151057:

The first question is what do you mean by today? Note in particular
that your date may not be the same as mine if we are in different
timezones.

Same year, same month and same date. And I think that all of my visitors
are in the same time zone and it is not so important, about the same
day…

if @post.updated_at.strftime("%d-%m-%Y") !=
Time.now.strftime("%d-%m-%Y")

Or is there better way?

This is basic ruby…
–Rob
Sent from my phone…excuse any typos please!

On 29 June 2014 14:27, Fresh M. [email protected] wrote:

if @post.updated_at.strftime("%d-%m-%Y") !=
Time.now.strftime("%d-%m-%Y")

Or is there better way?

Those give you the dates in UTC, which may not be the same as the
local timezone date.

Colin

Read up on the Date class. You can compare dates directly, and you have
the whole range of < = > operators to work on them.

Walter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs