Reputation: 3668
i'm compiling a church register and the dates are in this format yyyy-mm-dd example. 1978-03-27 .I need to make it 27th March,1978. Any php script to help me out? I tried MSEXcel but messes it up. thanks (anyway..i'm getting it from a database) so i would be glad if i have it been read from a database or a file of dates.
Upvotes: 0
Views: 146
Reputation: 16304
Try this:
$in = '1978-03-27';
$out = date('jS F Y',strtotime($in));
var_dump($out);
date()
formats your output, and strtotime()
converts your input to a timestamp. Keep in mind this will only work for values from 1970-01-01. If you want to work with "older" dates, you have to parse the input manually and generate the output you require.
Upvotes: 0