[ create a new paste ] login | about

Link: http://codepad.org/PTWUocx9    [ raw code | output | fork ]

PHP, pasted on Oct 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

function literalDate($timestamp) {
	$timestamp = is_numeric($timestamp) ? $timestamp : strtotime($timestamp);
	$weekday = date('l', $timestamp);
	$month = date('M', $timestamp);

	$ord = 1;

	while(date('M', ($timestamp = strtotime('-1 week', $timestamp))) == $month) {
		$ord++;
	}

	$lit = array(null, 'first', 'second', 'third', 'fourth', 'fifth');

	return strtolower($lit[$ord].' '.$weekday);
}

echo literalDate('2010-10-21');


Output:
1
third thursday


Create a new paste based on this one


Comments: