0

How to convert python datetime to AWSTimestamp - appsync scalar type?

Python format: 2021-07-14 09:11:48.563323

to

AWSTimestamp format: 1930-01-01T16:00:00-07:00
Thirumal
  • 8,280
  • 11
  • 53
  • 103
  • your "Python format" doesn't have UTC offset information while your "AWSTimestamp format" does have it. Could you please clarify? – FObersteiner Jul 14 '21 at 09:29

2 Answers2

0

Use the below method to convert python datetime to AWSTimestamp

def convert_to_aws_timestamp(timestamp):
        return str(timestamp)[:-3].replace(" ", "T") + "Z"
Thirumal
  • 8,280
  • 11
  • 53
  • 103
0

Try to user strftime from a datetime

For example something like

myDate.strftime('%Y-%m-%dT%H:%M:%S.000Z')

To obtain "2022-09-27T08:32:51.000Z"

But anyway your format looks strange, try to add more information, as was asked by FObersteiner

dr.s
  • 11
  • 3