Created
April 6, 2011 20:05
-
-
Save alexpgates/906408 to your computer and use it in GitHub Desktop.
Use DayOne data with php.
This file contains 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 | |
// DayOne is a nice little journaling app for iOS / Mac (available via App Store). | |
// This code requires php_class_lib available here: https://github.com/jsjohnst/php_class_lib | |
include('php_class_lib/classes/parsers/plist/PlistParser.inc'); | |
// grab filenames for all of your journal entries | |
$entries = array(); | |
if ($handle = opendir('/path/to/your/Journal.dayone/entries')) { | |
while (false !== ($file = readdir($handle))) { | |
if($file != '.' && $file != '..'){ | |
$entries[] = $file; | |
} | |
} | |
closedir($handle); | |
} | |
// loop through each entry and display title, date, and content | |
foreach($entries as $entry){ | |
$parser = new plistParser(); | |
$plist = $parser->parseFile("/path/to/dayone/Journal.dayone/entries/$entry"); | |
$stamp = strtotime($plist['Creation Date']); | |
$entry_text = nl2br($plist['Entry Text']); | |
$entry_year = date('Y', $stamp); | |
$entry_month = date('F', $stamp); | |
$entry_date = date('d', $stamp); | |
?> | |
<h1><?php echo $entry_month.' '.$entry_date.', '.$entry_year; ?> </h1> | |
<p><?php echo $entry_text; ?></p> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment