Timestamp Handling

Handling Timestamps when making API calls

Introduction

When making API calls, you will often need to specify a timestamp. Always use the datetime utility functions to convert a DateTime object to a string in the correct format.

Examples

const formattedStartDate = getAPIDateTimeFormat(momentDate);
useEffect(() => {
  // get the start of the month and end of the month dates
  setPeriodStartDate(getAPIDateTimeFormat(moment().startOf("month")));
  setPeriodEndDate(getAPIDateTimeFormat(moment().endOf("month")));
 
  return () => {};
}, []);

Getting start and end of day

useEffect(() => {
  // get the start of the month and end of the month dates
  setPeriodStartDate(getAPIDateTimeFormat(moment().startOf("month")));
  setPeriodEndDate(getAPIDateTimeFormat(moment().endOf("month")));
 
  return () => {};
}, []);

Looking for date and time handling examples? Check out the date-time-handling.md file.