Implement timedeltas for to_json

Closes #9027