Loading...

Format Xero dates from the API

David Carr

1 min read - 2nd Sep, 2021

Format Xero dates from the API

Dates in Xero that are not already set to a datestring are in a format like Date(1518685950940+0000)

How to format these

They are made up from unix timestamps in milliseconds rather than seconds, they need to be converted by taking the timestamp and times by 1,000

date("Y-m-d", 1518685950940 / 1000)

This will give you the formatted date.

When doing this over the API dynamically you can do this:

if (isset($inv['FullyPaidOnDate'])) {
    $date = str_replace('/Date(', '', $inv['FullyPaidOnDate']);
    $parts = explode('+', $date);
    $paidAt = date("Y-m-d", $parts[0] / 1000);
}

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

0 comments
Add a comment