year函数 有关问题,在线给分
year函数 问题,在线给分
如$year=过的年数,如5
$staff_join=开始的年月日 如2008-05-02
我现要 把开始的年月日加上年数,如 2008-05-02+5=2013-05-02 用什么表达式呀,
要可运行的代码,谢谢
小弟这样 ($Begin=(date("Y",$staff_join)+$year) 出错, 输出1970)
------解决方案--------------------
- PHP code
<?php $year = 5; $staff_join ="20010-05-02"; $a = strtotime("+".$year." Year")-time(); $staff_join = strtotime($staff_join)+$a; echo date('Y-m-d',$staff_join); ?> <br><font color="#e78608">------解决方案--------------------</font><br>这里赋值写错了<br>$staff_join ="20010-05-02";<br>改成$staff_join ="2010-05-02"; <br><font color="#e78608">------解决方案--------------------</font><br>
- PHP code
$year = 5; $staff_join = '2008-05-02'; $arrdate= explode('-',$staff_join); $arrdate[0] += $year; $staff_out = implode('-',$arrdate); echo $staff_out; //2013-05-02 echo "<br>"; echo $arrdate[0]; //2013 ?> <br><font color="#e78608">------解决方案--------------------</font><br><pre class="brush:php;toolbar:false"><br><?php <br />$year = 5;<br>$staff_join='2008-05-02';<br><br>$join_date = mktime(0, 0, 0, <br> substr($staff_join, 5, 2), substr($staff_join, -2, 2), substr($staff_join, 0, 4));<br>echo date('Y-m-d', $join_date), "\n";<br>$join_date_5_years_later = <br> strtotime("+$year Year", $join_date );<br><br>echo date('Y-m-d', $join_date_5_years_later);<br>?><br>
------解决方案--------------------
- PHP code
<?php $value = 5; $year = date('Y'); $year += $value; echo $year.date('-m-d'); <br /><font color="#e78608">------解决方案--------------------</font><br>$year = 5; <br>$staff_join = '2008-05-02';<br><br>$Begin = date("Y-m-d", strtotime("+$year year $staff_join));<br> <br><font color="#e78608">------解决方案--------------------</font><br>给楼上老大改下<br><?php <br />$year = 5; <br>$staff_join = '2008-05-02'; <br><br>$Begin = date("Y-m-d", strtotime("+$year year $staff_join")); <br>echo $Begin;<br>?> <br><font color="#e78608">------解决方案--------------------</font><br><?php <br />$year = 5; <br>$staff_join = '2008-05-02'; <br><br>$Begin = date("Y-m-d", strtotime("+$year year,$staff_join")); <br>echo $Begin;<br>?> <br><font color="#e78608">------解决方案--------------------</font><br>看来已经解决了 <br><font color="#e78608">------解决方案--------------------</font><br>strtotime <br><font color="#e78608">------解决方案--------------------</font><br>老兄去研究一下strtotime函数,手册上有详细说明。 <div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The meaning of JOIN is just like the English word "join". It joins two tables and can be roughly divided into inner join, outer join, right join, left join and natural join. First create two tables, the following is used as an example CREATETABLEt_blog(idINTPRIMARYKEYAUTO_INCREMENT,titleVARCHAR(50),typeIdINT);SELECT*FROMt_blog;+----+------+--------+| id|title|typeId|+----+-------+--------+|1|aaa|1||2|bbb|2||3|ccc|3|

When developing using PHP programs, you often encounter some warning or error messages. Among them, one error message that may appear is: PHPWarning:date()expectsparameter2tobelong,stringgiven. The error message means: the second parameter of the function date() is expected to be a long integer (long), but what is actually passed to it is a string (string). So, we

If you're looking for a way to automatically create and name files and folders based on system timestamps, you've come to the right place. There is a super simple way to accomplish this task. The created folders or files can then be used for various purposes such as storing file backups, sorting files based on date, etc. In this article, we will explain in some very simple steps how to automatically create files and folders in Windows 11/10 and name them according to the system’s timestamp. The method used is a batch script, which is very simple. Hope you enjoyed reading this article. Section 1: How to automatically create and name a folder based on the current timestamp of the system Step 1: First, navigate to the parent folder where you want to create the folder,

Join type leftjoin uses the left table as the driving table and the left table as the basis of the result set. The data from the right table is connected to the result set. rightjoin uses the right table as the driving table and the right table as the basis of the result set to connect the left table. The data is added to the result set innerjoin. The result set takes the intersection of the two tables fulljoin. The result set takes the union of the two tables. MySQL does not have a fulljoin. The difference between union and unionall is that union will deduplicate the crossjoin Cartesian product. If the where condition is not used, the result set will be the product and of the two associated table rows. The difference is that when crossjoin creates the result set, it will be passed according to the on condition.

1. Introduction The Date class in the java.util package represents a specific time, accurate to milliseconds. If we want to use our Date class, then we must introduce our Date class. Writing the year directly into the Date class will not produce the correct result. Because Date in Java is calculated from 1900, so as long as you fill in the first parameter with the number of years since 1900, you will get the year you want. The month needs to be subtracted by 1, and the day can be inserted directly. This method is rarely used, and the second method is commonly used. This method is to convert a string that conforms to a specific format, such as yyyy-MM-dd, into Date type data. First, define an object of Date type Date

How to get millisecond representation of date using getTime() method of Date class In Java, Date class is a class used to represent date and time. It provides many useful methods to manipulate and obtain information about date objects. Among them, the getTime() method is an important method in the Date class, which can return the millisecond representation of the date object. Next, we will detail how to use this method to obtain the millisecond representation of a date, and provide corresponding code examples. Using the Date class

There are many excellent calendar libraries and date libraries in Python for us to use. These libraries can help us handle date and calendar related operations. Next, I will introduce you to several common choices and provide corresponding code examples. Datetime library: Datetime is Python's built-in date and time processing module. It provides many date and time related classes and methods, which can be used to process dates, times, time differences and other operations. Sample code: importdatetime#Get the current date

Stringbuild class Since the object content of the String class cannot be changed, a new String object will be constructed every time it is spliced, which is time-consuming and wastes memory space. At this time, you need to solve this problem through the StringBuild class provided by Java. StringBuilder is also called a variable character sequence. , it is a string buffer similar to String, which can be regarded as a container. Many strings can be held in the container. Variable means that the content in the StringBuilder object is variable. The construction method publicStringBuilder(): creates an empty buffer publicStringBuilder(Stringsr
