---
# System prepended metadata

title: 蘇 interview

---

# 蘇 interview

## Q1.
取出工作經歷(employmentHistory)中，任職最久的一份工作
```php=
<?php

$payload = '{
  "employmentHistory": [
    {
      "employer": "JKL Inc.",
      "position": "Web Developer",
      "startDate": "2008-01-01",
      "endDate": "2009-12-31"
    },
    {
      "employer": "ABC Inc.",
      "position": "Software Engineer",
      "startDate": "2010-01-01",
      "endDate": "2012-06-30"
    },
    {
      "employer": "MNO Corp.",
      "position": "Software Engineer",
      "startDate": "2010-01-01",
      "endDate": "2011-12-31"
    },
    {
      "employer": "XYZ Corp.",
      "position": "Senior Software Engineer",
      "startDate": "2012-07-01",
      "endDate": "2013-12-31"
    },
    {
      "employer": "UVW Inc.",
      "position": "Senior Software Engineer",
      "startDate": "2012-01-01",
      "endDate": "2014-12-31"
    },
    {
      "employer": "Acme Corp.",
      "position": "Lead Software Engineer",
      "startDate": "2014-01-01",
      "endDate": "2015-12-31"
    },
    {
      "employer": "DEF Inc.",
      "position": "Software Developer",
      "startDate": "2016-01-01",
      "endDate": "2017-12-31"
    },
    {
      "employer": "GHI Corp.",
      "position": "Systems Analyst",
      "startDate": "2018-01-01",
      "endDate": "2019-12-31"
    },
    {
      "employer": "LMN Inc.",
      "position": "Senior Systems Analyst",
      "startDate": "2020-01-01",
      "endDate": "2021-06-30"
    },
    {
      "employer": "PQR Corp.",
      "position": "Software Engineer",
      "startDate": "2021-07-01",
      "endDate": null
    }
  ]
}';


// hint: 
// int(1678850600)
$start = (new DateTimeImmutable($startDate))->getTimestamp();
$end = (new DateTimeImmutable($endDate))->getTimestamp();
$diff = $end - $start;

```