Bir haftanın ilk tarih

6 Cevap

I want a First Day Of a week say I have 45th week. Now I want to have date of the first sunday of this week. Can any one suggest me how I can go about this ?

Teşekkür ederim

6 Cevap

Biraz etrafında arama, en, önerilen:

$year = "2009"; // date("Y");
$week = "45"; // date("W");

$firstDayOfWeek = strtotime($year."W".str_pad($week,2,"0",STR_PAD_LEFT));

print("The first day of week ".$week." of ".$year." is ".date("D, d-m-Y",$firstDayOfWeek));

Basically this comes down to letting strtotime do the work for you. You fill in "2009W45" and it'll retrieve the date for you. Pitfall here is that the week needs to be in a 2 digit format. So week 1 needs to be 01, hence the str_pad to zero-fill it.

Eğer gerekir strtotime ve date function

gibi bazı kod

$next_sunday = strtotime('next sunday');
$next_week = strtotime('+1 week');
$next_sunday_of_next_week = strtotime('next sunday', $next_week);

Bu yardımcı olur umarım

Eğer ay, gün ve yıl varsa:

$timestamp = mktime(0, 0, 0, $month, $day, $year);
 echo date('c', $timestamp) = mktime(0, 0, 0, $month, date('d', $timestamp)-date('w', $timestamp), $year);

Eğer zaman damgası varsa siz de bu şekilde yapabiliriz:

echo $date('c', mktime(0, 0, 0, $month, date('d', $timestamp)-date('w', $timestamp), $year));

Gönderen: http://pinoytech.org/blog/post/get-the-first-day-of-the-week-with-an-exact-date

date($str_format, strtotime($year."W".$week."1"))

$str_format PHP date() function .. kullandığım 'M d Y' göre, çıkış format olduğu yerde

this bazı fikir almak için bkz.

Bize biraz daha fazla ayrıntı sağlayabilir eğer Biz sadece bunu başarmak istediğiniz dilde, size yardımcı olabilir, Açıkçası bu herhangi laguage, komut dosyası veya veritabanı üzerinde yapılması gerekiyor belirtin?