getting the last day of the month |
I am using DatePicker to have a user set the date.
Code: <form method="post"> the user can enter for example 201906 which to me means the last day of June, 2016. But when I get the value from Code: if (!empty($_POST["datePicker"])) { The date I get is 20190601 (in YYYYMMDD). I really need it to be 20190630. The reason is that I need to get a period of 365 days. I see that there is some way to use srtotime to specify one year before, but it would help if the unix style date was the end of the month, not the start of the month.
proof that an old dog can learn new tricks
Hi. Use:
PHP Code: echo gmdate("Y-m-t", $timestamp); Use "t" to get the number of days in a month. https://www.php.net/manual/en/datetime.format.php |
Welcome Guest, Not a member yet? Register Sign In |