Pergunta

I've been querying stream table to search for a post that was published a few months back with this query:

SELECT post_id, message  FROM stream WHERE source_id=group_ID and actor_id=USER_ID

However, it's not returning any result because the post's publication date is not current. So I've wanted to specify the updated_time field in this table.

What would be the correct value for updated_time if I want it to be not less than 3 months back?

say, updated_time < now() and updated_time > 3_months_before

Thanks in advance.

Foi útil?

Solução

updated_time is the UNIX timestamp

In PHP you can use strtotime-

strtotime("-3 month") //3 months ago
strtotime("now") //now

In Javascript-

var d = new Date();
d.setMonth(d.getMonth() - 3);
Math.round(d.getTime() / 1000); //3 months ago

Math.round((new Date()).getTime() / 1000); //now
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top