Skip to content

Instantly share code, notes, and snippets.

View cescgie's full-sized avatar

Cescgie cescgie

  • Beschuetzerbox GmbH
  • Berlin, Germany
View GitHub Profile
@cescgie
cescgie / gist:15e0776820d1372ff8ff
Last active September 9, 2015 10:36 — forked from ozh/gist:8169202
Human readable time difference between 2 dates in PHP
<?php
/**
* Get human readable time difference between 2 dates
*
* Return difference between 2 dates in year, month, hour, minute or second
* The $precision caps the number of time units used: for instance if
* $time1 - $time2 = 3 days, 4 hours, 12 minutes, 5 seconds
* - with precision = 1 : 3 days
* - with precision = 2 : 3 days, 4 hours
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}