Introducing the Chargebee CLI

Error "Should be in valid date format" via API

Problem Statement

This article explains why the API returns the error "Term Ends At: Should be in valid date format" (or similar for time-related fields) and how to fix it.

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.