Skip to content

Instantly share code, notes, and snippets.

View philsturgeon's full-sized avatar
🌳
Planting Trees

Phil Sturgeon philsturgeon

🌳
Planting Trees
View GitHub Profile
@philsturgeon
philsturgeon / gist:3228301
Created August 1, 2012 16:12
Tricky Date Formating
<?php
function formatDate($strDate) {
$parts = explode(' ', $strDate);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
// check to see if it is am or pm
if(strtolower($parts[2]) == 'pm' && $times[0] != 12) {
// add 12 to the hour as it needs to be military time
$times[0]+=12;
}
@philsturgeon
philsturgeon / gist:3228398
Created August 1, 2012 16:21
Simple DateTime Conversion
<?php
function formatDate($strDate) {
return DateTime::createFromFormat("m/j/Y g:i:s A", $strDate)->format('Y-m-d H:i:s');
}
@philsturgeon
philsturgeon / gist:3228471
Created August 1, 2012 16:28
Complicated Compare date difference (Seconds)
<?php
function calculateDateDiff($strStart, $strEnd) {
$parts = explode(' ', $strStart);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
$unix_start = mktime($times[0], $times[1], $times[2], $dates[0], $dates[1], $dates[2]);
$parts = explode(' ', $strEnd);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
@philsturgeon
philsturgeon / gist:3228499
Created August 1, 2012 16:30
DateTime comparison (strings)
<?php
function calculateDateDiff($strStart, $strEnd) {
$objStart = DateTime::createFromFormat("m/j/Y g:i:s A", $strStart);
$objEnd = DateTime::createFromFormat("m/j/Y g:i:s A", $strEnd);
// Return Total Seconds
return $objEnd->getTimestamp() - $objStart->getTimestamp();
// Return formatted diference (7hrs 5mins and 43 seconds)
return $objStart->diff($objEnd)->format('%hhrs %imins and %sseconds ');
@philsturgeon
philsturgeon / gist:3343945
Created August 13, 2012 20:38
Dutch DBAD
WEES GEEN LUL PUBLIEKE LICENTIE
Versie 1, December 2009
Copyright (C) 2009 Philip Sturgeon <[email protected]>
Iedereen heeft toestemming dit document te kopiëren en te distribuëren,
en veranderen is toegestaan als je de naam van het document verandert.
WEES GEEN LUL PUBLIEKE LICENTIE
@philsturgeon
philsturgeon / composer.json
Created September 19, 2012 09:37
PHP Image Manipulation
{
"require": {
"illuminate/foundation": ">=1.0.0",
"illuminate/auth": ">=1.0.0",
"illuminate/database": ">=1.0.0",
"illuminate/view": ">=1.0.0",
"amazonwebservices/aws-sdk-for-php": "1.5.*",
"codeguy/upload": "*",
"sybio/image-workshop" : "*",

DON'T BE A DICK PUBLIC LICENSE

Version 1, December 2009

Copyright (C) 2009 Philip Sturgeon [email protected]

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Operating System
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
@philsturgeon
philsturgeon / gist:4197232
Created December 3, 2012 19:15
Lex: Is Monday?
{{ if {helper:date format="D"} == "Mon" }}
<p>Bla</a>
{{ endif }}
@philsturgeon
philsturgeon / Gemfile
Last active December 10, 2015 12:08
Create a GPX file of Foursquare checkins
source 'https://rubygems.org'
gem "json"
gem "typhoeus"
gem "quimby"