Topic: Converting datetimepicker display text to an API timestamp

frontendLab free asked 2 weeks ago


Our picker uses a local display format, but the endpoint expects a machine readable timestamp.

Is there a recommended conversion that avoids ambiguous date parsing?


Igor Przybysz staff answered 2 weeks ago


Keep the localized display format separate from the API contract. Parse the date and time according to the format you configured, validate the individual fields, and apply the intended time zone before producing the endpoint's timestamp. Avoid passing an ambiguous day/month display string to the Date constructor and relying on browser-specific parsing.

For an API that accepts instants, an ISO string with an explicit offset or UTC is a suitable contract once the intended instant is established. Please send your configured format, one example selection, and the endpoint's expected representation. Appointments stored as local wall-clock times require an explicit time-zone agreement as well.

https://mdbootstrap.com/docs/standard/forms/datetimepicker/



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 9.3.0
  • Device: Desktop
  • Browser: Firefox
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: No