# Sending the correct time to DatePicker in PHP?

**URL:** <https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936>\
**Category:** APIs & Integrations\
**Created:** [March 10, 2022, 8:40pm UTC](https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936 "2022-03-10T20:40:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TLane](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@TLane](https://community.hubspot.com/u/TLane)\
**Post date:** [March 10, 2022, 8:40pm UTC](https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936/1 "2022-03-10T20:40:49Z")

</div>

Hello, i’m trying to figure out how to send a time stamp correctly to a datepicker property. I’ve done some research on here but can’t really find a answer.

Here’s what I got:

$time = 1632182399;

I had did some research and found a contributor had suggested this solution: [https://community.hubspot.com/t5/APIs-Integrations/Update-Custom-Date-Picker-in-Deals-through-the-API/m-p/229499](https://community.hubspot.com/t5/APIs-Integrations/Update-Custom-Date-Picker-in-Deals-through-the-API/m-p/229499)

But this doesn’t actually work and I don’t know why. Perhaps I’m calling it wrong? This is what I was trying:

```auto
function get_time_for_hubspot($time){
 $date = new DateTime();
 $date->setTimestamp($time);
 return gmdate('Y-m-d H:i:s', strtotime($date->format('Y-m-d H:i:s')));
}

```

`// Time Stamps $starttime = strval($booking_object->start); $endtime = strval($booking_object->end); $starttime = get_time_for_hubspot($starttime); $endtime = get_time_for_hubspot($endtime);`

Which produces:  
$starttime = 2021-09-13 00:00:00  
$endtime = 2021-09-13 23:59:59

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [March 10, 2022, 8:58pm UTC](https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936/2 "2022-03-10T20:58:28Z")

</div>

@TLane

Make sure you send your timestamp in milliseconds. You are a few digits shy there 😀

$time = 1632182399; should be

$time = 1646945881755

---

<div class="post-metadata">

**Author:** ![TLane](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@TLane](https://community.hubspot.com/u/TLane)\
**Post date:** [March 10, 2022, 9:06pm UTC](https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936/3 "2022-03-10T21:06:03Z")

</div>

Thanks Dennis. Are you supposed to send the time as just the milliseconds or are you supposed to convert it to UTC and send that?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [March 10, 2022, 9:16pm UTC](https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936/4 "2022-03-10T21:16:02Z")

</div>

Nope. Just send as a unix timestamp in mills

---

<div class="post-metadata">

**Author:** ![TLane](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@TLane](https://community.hubspot.com/u/TLane)\
**Post date:** [March 10, 2022, 9:18pm UTC](https://community.hubspot.com/t/sending-the-correct-time-to-datepicker-in-php/52936/5 "2022-03-10T21:18:29Z")

</div>

Hmm okay. Do you by chance know the logic i’d use to convert that to a unix timestamp in mills in PHP ? :V Its the one thing I can’t seem to figure out correctly!
