php - 在年末输入当年的总值

标签 php mysql

我想在年底时添加年度总值。我的 MySQL 查询没问题,但我的年底识别函数出错了。您能帮我改进我的查询吗?

if ($day== date(strtotime("-12-31")) {
    $query1=mysql_query($sql1) 
}

最佳答案

strtotime非常灵活。请注意时区。 您可以按如下方式获取一年中的最后一天。

date('Y-m-d', strtotime('last day of december'));

引自手册。

Each parameter of this function uses the default time zone unless a time zone is specified in that parameter. Be careful not to use different time zones in each parameter unless that is intended. See date_default_timezone_get() on the various ways to define the default time zone.

关于php - 在年末输入当年的总值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20851433/

相关文章:

php - 使用 Gsuite 邮件时电子邮件在 laravel 上不起作用

php - 从字符串 PHP 中删除空格并插入数据库

php - 双重复 key 更新输入错误

sql - 从 MySQL 中的日、月、年字段创建日期

php - 添加 PHP Prestashop 模块后获取产品 ID

javascript - 在 Laravel Blade 中的 foreach 循环上使用 javascript 函数

php - 在 PHP 中添加到多维数组

mysql - SQL 查询无法检索多个结果

php - App Engine (PHP) 与 Cloud SQL 的连接失败

php - 时间戳在 phpmyadmin 中显示错误的时间