Skip to content

Datetime inside lambda giving same time for different invocations.

0

I have a lambda function that writes to dynamodb and inside the lambda, I fetch current time and pass it as well with data as the write time. I have noticed that in the DB, the datetime for the write is same for multiple invocations although they were not together. at least a gap of few minutes was there before each invocation. however, in db, the datetime is the exact including seconds for a few calls that were within a timespan of 15 minutes or so. Can I know why?

asked 3 years ago1.2K views

2 Answers
1
Accepted Answer

Are you getting the current time inside the handler or outside the handler? The code that runs outside the handler is invoked only once. In your case, you need to do it inside the handler.

If this is not the case, it would be good if you can share your code.

AWS
EXPERT

answered 3 years ago

EXPERT

reviewed 3 years ago

EXPERT

reviewed 3 years ago

0

Hey, thanks. It's outside the handler. I will put it inside.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.