In python

codice:
#!/usr/bin/env python

import datetime

now = datetime.datetime.now()
delta = datetime.timedelta(days = 7)
a_week_ago = now - delta
print a_week_ago
print a_week_ago.strftime("%Y%m%d%H%M%S")
da come output:

codice:
$ ./a_week_ago.py 
2006-12-21 17:45:50.310571
20061221174550
Cancella il "print" che non ti serve