0

When calling an API, I need to provide a start time and an end time in ISO 8601 format (UTC time).

I want to call the API in a CRON job, so I can't manually create the date-time(s).

How can I use the date command to achieve what I want?

Note: I have already read other questions, where the answers show how to output the current date-time, like TZ=GMT date +"%Y-%m-%dT%H:%M:%SZ". This doesn't provide a solution for outputting a date-time into the future.

Example API payload:

{
  "displayName": "string",
  "endDateTime": "2024-03-12T07:06:44.266Z",
  "startDateTime": "2024-03-12T07:06:44.266Z"
}
Shuzheng
  • 4,411

1 Answers1

1

How far into the future?

 date --date=tomorrow
 date --date='1 year'
 date --date='3 days 1 year'
user10489
  • 6,740