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
- Convert the date and time to a UTC timestamp in seconds using a Unix time converter (for example, epochconverter.com).
- Pass a numeric timestamp in seconds in the API payload, not milliseconds.
- 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.