<?php/** This function figures out what fiscal year a specified date is in.* $inputDate - the date you wish to find the fiscal year for. (12/4/08)* $fyStartDate - the month and day your fiscal year starts. (7/1)* $fyEndDate - the month and day your fiscal year ends. (6/30)* $fy - returns the correct fiscal year*/function calculateFiscalYearForDate($inputDate, $fyStart, $fyEnd){$date = strtotime($inputDate);$inputyear = strftime('%Y',$date);

This is that worked with UTF-8 encoding on Linux server, with right accents:<?phpsetlocale(LC_ALL, 'hu_HU.UTF8');echo(strftime('%Y. %B %d. %A'));?>

Output is:2009. november 02. hétfő

Also, this one can be used, if not utf-8 preferred:<?phpsetlocale(LC_ALL, 'hu_HU.ISO8859-2');?>

UTF-8 is not supported on windows platforms, so there the iconv workaround must be used:<?phpsetlocale(LC_ALL, 'hun_hun');echo(iconv('ISO-8859-2', 'UTF-8',strftime('%Y. %B %d. %A')));?>

The output is the same as before. Note that, the iconv first parameter is ISO-8859-2 not ISO-8859-1, because the locale is hungarian which uses 8859-2 codepage as default. It is needed for the right accents.

If you want use the same code for Windows and Linux platforms, the second one is the right option (the iconv trick), but the locale configuration must be different (Linux: hu_HU, windows: hun_hun), but in that case the UTF8 tag is not needed for the Linux config.

if($format=='%V' or $format=='%G' or $format=='%g'){ // When strftime("%V") fails, some unoptimized workaround // // http://en.wikipedia.org/wiki/ISO_8601 : week 1 is "the week with the year's first Thursday in it (the formal ISO definition)"

%V may fail with some systems (Windows XP, at least). Here is a function that should work to get the week number of a day (timestamped), according to ISO 8601.

"should work" as in "it is working with my understanding of this norm", where 1st of january can be week 52, 53 or 01. Hopefully.

testing (php_uname("s") == "Windows NT") or equivalent can be an option (when switching between Wampserver and a GNU server, for instance).

Please, erase and correct my message if there is any error.

<?phpfunction week_isonumber ($time) {// When strftime("%V") fails, some unoptimized workaround//// http://en.wikipedia.org/wiki/ISO_8601 : week 1 is "the week with the year's first Thursday in it (the formal ISO definition)"

I had a need to subtrackt an older time from current time to get the time between. Example: If one has worked from 2009-03-16 11:33:54 to 2009-03-16 12:01:54 then he has worked X hours,minutes and seconds. I tried to find that X. And so - one solution would be:<?php$start_date = strtotime("2009-03-16 11:33:54"); //start date from database - date("Y-m-d H:i:s") made as UNIX timestamp$end_date = strtotime("2009-03-16 12:01:54"); //end date from database - date("Y-m-d H:i:s") made as UNIX timestamp$ajavahe = $end_date - $start_date;$time_between = gmstrftime('%Hh %Mm %Ss', $ajavahe); //gmstrftime() deals with different timezones correctly. (If in example you would be situated in Estonia and you would use strftime() you get wrong answer off by 2 hrs, because timezone is GMT+2 - with gmstrftime() comes right answer.)

echo 'You have worked: '.$time_between;?>Hope that this one makes someones life easier :D

If you are like me and only leave in the system the locales you use normally (en_US and your own language locale, like es_ES), you'll only be able to use the locales installed. If your application is translated to other languages, you need these locales too.

The name of the locale in your system is important too. This can be a problem when you want to distribute the app.

If you have this locales in your system:en_US/ISO-8859-1en_US.UTF-8/UTF-8es_ES/ISO-8859-1es_ES@euro/ISO-8859-15es_ES.UTF-8/UTF-8es_ES@euro/UTF-8

and use setlocale('es_ES'), the result will use the iso-8859-1 charset even if you have all your system, files and configuration options in UTF-8. To receive content in UTF-8, in this example, you need to use setlocale('es_ES.UTF-8') or setlocale('es_ES.UTF-8@UTF-8').

The definition of locales can change from one system to another, and so the charset from the results.

$new_date=substr_replace($date,'1980',0,4); # we replace the year by a year after 1970
$new_format=eregi_replace('%a|%A|%u','',$format); # we remove days information from the format because they would be wrong
$new_date=strftime($new_format,strtotime($new_date)); # we convert the date
$new_date=eregi_replace('1980',$year,$new_date); # we put back the real year
return $new_date;
}
else {
return strftime($format,strtotime($date));
}
}
}
?>