Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > อยากได้ วันที่ 1 ของปี 2019 ส่วน ของปีนี้ 2018 ทำได้ แต่ปี 2019 ทำไม่ได้ แนะนำที่ครับ ท่านผู้รู้



 

อยากได้ วันที่ 1 ของปี 2019 ส่วน ของปีนี้ 2018 ทำได้ แต่ปี 2019 ทำไม่ได้ แนะนำที่ครับ ท่านผู้รู้

 



Topic : 131010



โพสกระทู้ ( 430 )
บทความ ( 1 )



สถานะออฟไลน์
Blogger



Code (PHP)
<?php 
echo "--------------------".'<br>';


$week_next = strtotime('next month of year', time());
$month_start = strtotime('first day of month', time());


$month_Jan_NextY = strtotime('first day of next year', time());
$month_Jan_NextF = strtotime('for next year first day of February', time());





$year_January = strtotime('first day of January', time());
$year_February = strtotime('first day of February', time());
$year_March = strtotime('first day of March', time());
$year_April = strtotime('first day of April', time());
$year_May = strtotime('first day of May', time());
$year_June = strtotime('first day of June', time());
$year_July = strtotime('first day of July', time());
$year_August = strtotime('first day of August', time());
$year_September = strtotime('first day of September', time());
$year_October = strtotime('first day of October', time());
$year_November = strtotime('first day of November', time());
$year_December = strtotime('first day of December', time());


$year_1 = strtotime('next year of December', time());



echo date(' jS M Y', $year_January).'<br/>';
echo date(' jS M Y', $year_February).'<br/>';
echo date(' jS M Y', $year_March).'<br/>';
echo date(' jS M Y', $year_April).'<br/>';
echo date(' jS M Y', $year_May).'<br/>';
echo date(' jS M Y', $year_June).'<br/>';
echo date(' jS M Y', $year_July).'<br/>';
echo date(' jS M Y', $year_August).'<br/>';
echo date(' jS M Y', $year_September).'<br/>';
echo date(' jS M Y', $year_October).'<br/>';
echo date(' jS M Y', $year_November).'<br/>';
echo date(' jS M Y', $year_December).'<br/>';
echo "************".'<br>';
echo "ทำไม่ได้ช่วยหน่อย";
echo date(' jS M Y', $month_Jan_NextY).'<br/>';
echo date(' jS M Y', $month_Jan_NextF).'<br/>';

echo "-------------------".'<br>';
?>







Tag : PHP, HTML, CSS, HTML5, JavaScript, Google Chrome









ประวัติการแก้ไข
2018-05-09 15:15:20
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2018-05-09 15:13:56 By : Hararock View : 717 Reply : 8
 

 

No. 1



โพสกระทู้ ( 3,844 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์
Twitter Facebook

Code (PHP)
<?php
$start_year=2018;
$end_year=2019;
$time = date("M");
$months=array('January','February','March','April','May','June','July','August','September','October','November','December');
while($start_year<=$end_year){
	for($i=0;$i<12;$i++){
		$timestamp    = strtotime("first day of ".$months[$i]."$start_year");
		echo date(' jS M Y', $timestamp).'<br/>';
	}
	$start_year++;
}

uuuuuuu








ประวัติการแก้ไข
2018-05-10 09:50:08
2018-05-10 09:50:48
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-10 09:47:37 By : mongkon.k
 


 

No. 2



โพสกระทู้ ( 430 )
บทความ ( 1 )



สถานะออฟไลน์
Blogger

ตอบความคิดเห็นที่ : 1 เขียนโดย : mongkon.k เมื่อวันที่ 2018-05-10 09:47:37
รายละเอียดของการตอบ ::
Thank you

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-10 13:54:15 By : Hararock
 

 

No. 3



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



สถานะออฟไลน์


Code (PHP)
$year_January = strtotime('first day of January', time());
$next_year_january = strtotime('+1 year', $year_january);

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-10 14:07:49 By : Chaidhanan
 


 

No. 4



โพสกระทู้ ( 430 )
บทความ ( 1 )



สถานะออฟไลน์
Blogger

ได้แบบนี้แทน เพราะไม่มีค่า ตายตัวสามารถเป็นปีใหม่ๆ ได้ Auto ไม่ต้องมา Config values
Code (PHP)
$year_A = strtotime('first day of January', time());
$A = date ('jS M Y',$year_A).'<br>';
echo $A; //1st Jan 2018


$February = strtotime('first day of February', time());
$February = date ('jS M Y',$February).'<br>';
echo $February; //1st Feb 2018


$year_B = strtotime( 'next year first day of January', time());
$B = date ('jS M Y',$year_B).'<br>';
echo $B; //1st Jan 2019


ส่วน ต้อง Covert string to int จื่งจะ Loop while ได้
Code (PHP)
$start_year = 2018;
$end_year = 2019;

$time = date("M");
$months=array('January','February','March','April','May','June','July','August','September','October','November','December');
while($start_year<=$end_year){
	for($i=0;$i<12;$i++){
		$timestamp    = strtotime("first day of ".$months[$i]."$start_year");
		echo date(' jS M Y', $timestamp).'<br/>';
	}
	$start_year++;
}

?>


แต่งงว่า Convert ยังไง
---------------


http://php.net/manual/en/function.strtotime.php
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-11 09:15:55 By : Hararock
 


 

No. 5



โพสกระทู้ ( 3,844 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์
Twitter Facebook

ตอบความคิดเห็นที่ : 4 เขียนโดย : Hararock เมื่อวันที่ 2018-05-11 09:15:55
รายละเอียดของการตอบ ::
เอาแบบที่เราถนัดและเข้าใจนะครับ ถูกต้องแล้ว

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-11 09:55:46 By : mongkon.k
 


 

No. 6



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



สถานะออฟไลน์


ระวังเรื่องการใช้ function time() ด้วยครับ ใช้เยอะๆเวลาจะเพี้ยนได้ กว่าจะ recheck เวลาอาจหายไปเป็น ชม.

Code (PHP)
define('cur_time', time()); 
แล้วเอา cur_time ไปใช้งาน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-11 12:15:30 By : Chaidhanan
 


 

No. 7



โพสกระทู้ ( 430 )
บทความ ( 1 )



สถานะออฟไลน์
Blogger

ตอบความคิดเห็นที่ : 5 เขียนโดย : mongkon.k เมื่อวันที่ 2018-05-11 09:55:46
รายละเอียดของการตอบ ::


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-11 13:43:07 By : Hararock
 


 

No. 8



โพสกระทู้ ( 430 )
บทความ ( 1 )



สถานะออฟไลน์
Blogger

ตอบความคิดเห็นที่ : 6 เขียนโดย : Chaidhanan เมื่อวันที่ 2018-05-11 12:15:30
รายละเอียดของการตอบ ::


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-05-11 13:46:46 By : Hararock
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากได้ วันที่ 1 ของปี 2019 ส่วน ของปีนี้ 2018 ทำได้ แต่ปี 2019 ทำไม่ได้ แนะนำที่ครับ ท่านผู้รู้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่