当前位置: 首页 > news >正文

PHP实现保质期计算器

1.php实现保质期计算, 保质期日期可选,天 、月、年

 

 

 2. laravel示例
/*** 保质期计算器* @return void*/public function expirationDateCal(){$produce_date = $this->request('produce_date');             // 生产日期$warranty_date = $this->request('warranty_date');           // 保质期$type = $this->request('type');                             // 类型 day month yearswitch ($type) {case "day":$date = date('Y-m-d', strtotime("+{$warranty_date} day", strtotime($produce_date)));$exp_date = date('Y-m-d', strtotime("-1 day", strtotime($date)));break;case "month":$date = date('Y-m-d', strtotime("+{$warranty_date} month", strtotime($produce_date)));$exp_date = date('Y-m-d', strtotime("-1 day", strtotime($date)));break;case "year":$date = date('Y-m-d', strtotime("+{$warranty_date} year", strtotime($produce_date)));$exp_date = date('Y-m-d', strtotime("-1 day", strtotime($date)));break;default:$exp_date = 0;}$exp_status = time() >= strtotime($exp_date) ? '已过期' : '未过期';return $this->jsonSuc(['result' => ['exp_date' => $exp_date, 'exp_status' => $exp_status] ?? []]);}

http://www.lryc.cn/news/121251.html

相关文章:

  • 【独立版】新零售社区团购电商系统生鲜水果商城兴盛优选十荟团源码
  • C++系列十:其他-1. Lua
  • 不知道打仗之害,就不知道打仗之利
  • 【leetcode】242. 有效的字母异位词(easy)
  • Windows电脑快速搭建FTP服务教程
  • Arduino驱动MQ2模拟烟雾传感器(气体传感器篇)
  • 常见分布式ID解决方案总结:数据库、算法、开源组件
  • 记录--Loading 用户体验 - 加载时避免闪烁
  • 系统架构设计专业技能 · 软件工程之软件测试与维护(六)【系统架构设计师】
  • 基于亚奈奎斯特采样和SOMP算法的平板脉冲响应空间插值matlab仿真
  • 柏睿向量数据库Rapids VectorDB赋能企业级大模型构建及智能应用
  • 装备合成(牛客)
  • C语言学习之一级指针二级指针
  • 【腾讯云 Cloud Studio 实战训练营】使用 Cloud Studio 快速构建 Vue + Vite 完成律师 H5 页面
  • Vim常用指令
  • 24届近3年青岛理工大学自动化考研院校分析
  • 进入现代云技术的世界-APIGateway、ServiceMesh、OpenStack、异步化框架、云原生框架、命令式API与声明式API
  • Macbook 终端 git 命令补全和提示
  • 2024考研408-计算机网络 第六章-应用层学习笔记
  • 使用阿里云服务器部署和使用GitLab
  • React入门学习笔记3
  • 从零开始理解Linux中断架构(25)中断运行全景实例
  • go-zero 是如何实现计数器限流的?
  • 【考研复习】24王道数据结构课后习题代码|第3章栈与队列
  • java中excel文件下载
  • 29 | 广州美食店铺数据分析
  • fastApi基础
  • Mysql整理二 - 常见查询语句面试题(附原表)
  • Python - 读取pdf、word、excel、ppt、csv、txt文件提取所有文本
  • Codeforces Round 892 (Div. 2) C. Another Permutation Problem 纯数学方法 思维题