Introducing the Chargebee CLI

Error "Should be in valid date format" via API

Problem Statement

The API returns "Term Ends At: Should be in valid date format", or a similar message for another time field, when the value is a date string or a timestamp in milliseconds. Chargebee expects a UTC timestamp in seconds.

Solution

Chargebee APIs expect time-related fields as UTC timestamps in seconds. If you send a date string or a value in milliseconds, the API returns this error. Convert your date and time to a Unix timestamp (UTC) in seconds before calling the API.

Steps to Set It Up

  1. Convert the date and time to a UTC timestamp in seconds using a Unix time converter (for example, epochconverter.com).
  1. Pass a numeric timestamp in seconds in the API payload, not milliseconds.
  2. Retry the API call with the corrected value.

Additional Information

  • Do not send timestamps in milliseconds; the API accepts only seconds.
  • Use an online Unix time converter to check your values if needed.