0

i have function for enter data in php for last date of month but how can i change in to first day of month.this is code for last day of month.

<?php 
$a_date= date("Y-m-d");
$last_date= date("Y-m-t", strtotime($a_date)); 
if($a_date==$last_date){ }else{ } 
?>
Ali
  • 3,479
  • 4
  • 16
  • 31
SasinduRHN
  • 31
  • 8

2 Answers2

1

First day of the month: date('Y-m-01');

Last day of the month: date('Y-m-t');

vonUbisch
  • 1,384
  • 17
  • 32
1
$a_date= date("j");
$last_date= date("t");
if($a_date==$last_date){ 
    // Last day of the month.
} elseif (date("j") == 1 {
    // First day of the month.
} else {
    // None of the above apply.
}
Fyntasia
  • 1,133
  • 6
  • 19