<?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
ได้แบบนี้แทน เพราะไม่มีค่า ตายตัวสามารถเป็นปีใหม่ๆ ได้ 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++;
}
?>