Last active
August 29, 2015 14:26
-
-
Save chriskacerguis/7e5f91bbb48bbe48bf7f to your computer and use it in GitHub Desktop.
How to convert an HeathKit NSDate time format to a Unix Timestamp for PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This will convert a iOS HealthKit Data Export startDate or endDate (NSDate format) | |
// into a DateTime Object for use in PHP | |
// Written by Chris Kacerguis | |
$nsdate = '20150802105200-0500'; | |
$format = 'YmdHis-O'; | |
$objDateTime = DateTime::createFromFormat('YmdHis', (int) $time); | |
$human_readable = $objDateTime->format('F d, Y h:ia'); | |
$unix_timestamp = $objDateTime->format('U'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment