Get n seconds before the target time. See Example Test Cases about the format.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def seconds_ago(s,n):
	

Solutions:
from datetime import *

def seconds_ago(s, n):
	return str(datetime.strptime(s, '%Y-%m-%d %H:%M:%S') - timedelta(seconds=n))


from datetime import datetime, timedelta

def seconds_ago(s, n):
	t = datetime.strptime(s, '%Y-%m-%d %H:%M:%S') - timedelta(seconds=n)
	return str(t.year).zfill(4) + t.strftime('-%m-%d %H:%M:%S')


from dateutil import parser
import datetime

def seconds_ago(s, n):
	timej = parser.parse(s) - datetime.timedelta(seconds=n)
	return str(timej)


import datetime, re
seconds_ago = lambda Q, S: str(datetime.datetime(*map(int, re.split('[- :]', Q))) - datetime.timedelta(0, S))
import datetime as dt


import datetime
seconds_ago = lambda s, n: str(datetime.datetime.strptime(s, '%Y-%m-%d %H:%M:%S') - datetime.timedelta(seconds=n))


import datetime

def seconds_ago(s, n):
	d = datetime.datetime.strptime(s, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(seconds=-n)
	return d.strftime('%Y').rjust(4, '0') + d.strftime('-%m-%d %H:%M:%S')