PHP primjer
==================
function lastOfMonth() {
return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
}
C# primjer
==================
public DateTime GetLastDayInMonth(int month, int year)
{
DateTime firstDay = new DateTime(year, month, 1);
DateTime lastDay = firstDay.AddMonths(1).AddDays(-1);
return lastDay;
}
- +/- sve poruke
- ravni prikaz
- starije poruke gore
Zašto C# nije ovakav
DateTime lastDay = new DateTime(year, 12, 31);
Edit: Sorry misli sam da je rijeć i zadnjem u godini,
DateTime d = new DateTime(year, month, DateTime.DaysInMonth(year, month));
....eto PHP mi je ružniji ,ma gledaj samo )))); zagrada , možda je jednostavniji ali nema takvu kontrolu koju ima C# i nije strongly type kao C#...
PHP primjer
==================
function lastOfMonth() {
return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
}
C# primjer
==================
public DateTime GetLastDayInMonth(int month, int year)
{
DateTime firstDay = new DateTime(year, month, 1);
DateTime lastDay = firstDay.AddMonths(1).AddDays(-1);
return lastDay;
}
A zašto mješaš kruške i jabuke?