2010-12-14 25 views
2

を使用して週番号から名前を月を見つけるために、PHPどのように、ノーノー月を見つけるためにどのようにPHP

+0

あなたは週を意味しますかそして年? –

+0

*(参照)* http://de.php.net/manual/en/function.date.php – Gordon

+0

しかし、私は私が出すと12月(12)を望む週何の50を持っていないと仮定 - \t を行うU任意のアイデアを持っている????????事前に感謝 – irshad

答えて

2

を使用して週番号から名前が(PHPの日付を見てください) - ここでhttp://php.net/manual/en/function.date.php

は、いくつかの良い例です:

<?php 
// set the default timezone to use. Available since PHP 5.1 
date_default_timezone_set('UTC'); 

// Prints something like: Monday 
echo date("l"); 

// Prints something like: Monday 8th of August 2005 03:12:46 PM 
echo date('l jS \of F Y h:i:s A'); 

// Prints: July 1, 2000 is on a Saturday 
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000)); 

/* use the constants in the format parameter */ 
// prints something like: Mon, 15 Aug 2005 15:12:46 UTC 
echo date(DATE_RFC822); 

// prints something like: 2000-07-01T00:00:00+00:00 
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000)); 
?> 
2
$myDate = "2010-05-12"; 

$weekNumber = date("W", strtotime($myDate)); 

はちょうどあなたが必要とする値を持つ "W" に置き換えます。全参照:

http://php.net/manual/en/function.date.php

あなたは週番号を持っている、とあなたが使用することができ、それから日付をしたい場合:

date("d m Y", strtotime("1.1.2010 + 30 weeks")); 
+0

こんにちはみんな、助けを借りて、 – irshad

+0

いいえ私は12月12日(12)を入れてほしい – irshad

+0

あなたはどんな考えを持っていますか????????事前に感謝 – irshad

8

お持ちの場合ISO weekの数字を入力してから、月を取得する(開始日の)y ISO週が週のあなたの意味と同じではないかもしれないことを心に留めて

// F = full name of month, n = month number without leading zero 
echo date('F n', strtotime('2010-W50')); 

ベア、とても読み:OUはstrtotimeなどを使用することができます。

あなたは今年の1月1日(関わらず、ある曜日の)Adnanが述べたように、あなたが行うことができますので、全体の週をカウントしたい場合:

echo date('F n', strtotime('1 Jan + 50 weeks')); 
関連する問題