Yammi
Yammi

Reputation: 465

PHP - Display the current date in words?

Is there a way to use getdate (or similar) to output the current day in a format like this

twenty october twenty ten

I can't have the year as 'two thousand ten' due to space restrictions so it just needs to be 'twenty eleven' 'twenty twelve' etc

Upvotes: 0

Views: 2250

Answers (2)

Alin P.
Alin P.

Reputation: 44346

You can't do this with PHP's date function. You can only output the month as string. To do what you asked for you need to get a number to word function (plenty are available out there) and apply it on your day - numberToWord( date('j') ), first part of the year - numberToWord( substr(date('Y'), 0, 2) ) and second part of the year - numberToWord( substr(date('Y'), 2, 2) ). The month is date('F').

Upvotes: 1

fabrik
fabrik

Reputation: 14365

Sure. Follow this tutorial then apply results to your date.

Note: you need to split year to two parts: 2010 = 20, 10

Upvotes: 3

Related Questions