Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nitinthewiz/4477950 to your computer and use it in GitHub Desktop.
<?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