How to remove any post that is older than X days in WordPress

To remove any post that is older than X days in WordPress you can use the query below.

Sample mySQL

DELETE FROM wp_posts WHERE post_type = 'post' AND DATEDIFF(NOW(), post_date) > X

How to get the seconds between two dates in Python

To get the seconds between two dates in Python you can use the following snippet.

Sample Python

import datetime
import time

def DateDiffSeconds(dateOlder, dateNewer):
  timedelta = dateNewer - dateOlder
  return timedelta.days*24*3600 + timedelta.seconds

dateOlder = datetime.datetime(2014,07,01,00,00,00)
dateNewer = datetime.datetime(2014,07,02,11,30,00)
print DateDiffSeconds(dateOlder,dateNewer)