# Get (exact) scheduled cron time in lambda

**URL:** <https://forum.serverless.com/t/get-exact-scheduled-cron-time-in-lambda/17145>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [May 10, 2022, 10:54pm UTC](https://forum.serverless.com/t/get-exact-scheduled-cron-time-in-lambda/17145 "2022-05-10T22:54:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sc112233](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sc112233](https://forum.serverless.com/u/sc112233)\
**Post date:** [May 10, 2022, 10:54pm UTC](https://forum.serverless.com/t/get-exact-scheduled-cron-time-in-lambda/17145/1 "2022-05-10T22:54:35Z")

</div>

Hi-

I’ve got a use case where I need to run a scheduled lambda via cron periodically, like every 15 minutes, and I need to query a DynamoDB table to for entries where the key is the exact epoch when the cron was scheduled to run. For example, if the lambda is scheduled to run at  
1/1/22 09:15:00, I need that epoch, and not the current time when the lambda is actually started (typically a few seconds later). Is there any way to get that “scheduled time” in the lambda function?

Alternatively it seems like I can probably take the current time and round it down to the 15 minute interval. Annoying, but not the end of the world I guess as long as the lambda never starts BEFORE the scheduled time. I assume that it always runs at or slightly after the scheduled time.

I really thought I saw this information in the past, but I can’t seem to find it in any of my current lambda cron logs…

Any suggestions would be appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![corin](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@corin](https://forum.serverless.com/u/corin)\
**Post date:** [May 12, 2022, 5:15pm UTC](https://forum.serverless.com/t/get-exact-scheduled-cron-time-in-lambda/17145/2 "2022-05-12T17:15:46Z")

</div>

The event data passed to the lambda from the CloudWatch schedule includes an event time. Here is a sample of what CloudWatch passes:

```auto
{
  "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c",
  "detail-type": "Scheduled Event",
  "source": "aws.events",
  "account": "123456789012",
  "time": "1970-01-01T00:00:00Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:events:us-east-1:123456789012:rule/ExampleRule"
  ],
  "detail": {}
}

```

I haven’t used the time field myself but I believe it is when the trigger fired.

---

<div class="post-metadata">

**Author:** ![mitchellpowers](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@mitchellpowers](https://forum.serverless.com/u/mitchellpowers)\
**Post date:** [May 17, 2022, 6:57am UTC](https://forum.serverless.com/t/get-exact-scheduled-cron-time-in-lambda/17145/3 "2022-05-17T06:57:41Z")

</div>

Hi, thanks for sharing.
