in PHP by adding or subtracting a day from a date, we get another date, and we'll use two examples to show that one is Strtotime and mktime the time to the time stamp to be processed again, the classmate who needs to see.
The following example: Date
This article contains the following content:1. Get the current date and time-how many ways do we have?2, change the way the date is displayed-the date and time of the display form3. Convert the current date to a Unix timestamp value4. Change the
1, year-month-day
echo Date (' y-m-j ');
2007-02-6
echo Date (' y-n-j ');
07-2-6
Uppercase Y represents the year four digits, while lowercase y represents the two digits of the year;
Lowercase m represents the number of months (with leading),
Date
(PHP 4, PHP 5)
date-formatting a local time/date
DescriptionString Date (string $format [, int $timestamp])
Returns a string that is the result of the timestamp of an integer in a given format string. If no timestamp is given, the local current
In PHP, the date () function is a function that can get time and date, it may be commonly used on the day of the month, I would like to share the date () function of the unknown parameter.
Date () function
This function is more familiar.
For daily Statistics, our date ("Ymd") is converted to integer as the primary key of the database, so it is necessary to use time to add and subtract when searching for a period of time statistic data;
For example, data within 30 days
function
The duration of the MSSQL database is: 2013-06-28 00:00:00
PHP input format is: 12:00AM
I used the method: Date ("Y-m-d Day", Strtotime ($rs 1[' DJRQ ')) Description: $rs 1[' djrq '] = 12:00AM
The result is: 1970-01-01
I want the format is: 2
Php
The interface is uploaded to PHP.2013-01-01 12:01:00$endtime = $this->input->get (' Endtime ');$endtime = Preg_replace ('/[-:]/', ' ', $endtime);The format now20130101120100 The format you want to implement is20130101000000How do I replace the
After obtaining the time through the date () function, it is found that the hour time is incorrect, which is 8 hours less than the current time. Both H and h are the same, this is because the Greenwich Mean Time is obtained, which is 8 hours
This article mainly introduces how to format the UNIX time using the date function of PHP. The example shows how to use the date function in php, for more information about how to format UNIX time using the date function of PHP, see the following
// Combine the functiondateserial ($ nyear, $ nmonth, $ nday) {returndate (Y/n/j, mktime (0, 0, 0, $ nmonth, $ nday, $ nyear);} $ now_rqdate (Y/n/j); // get the current date $ yeardate (Y); // get the year $ monthda
// The merging date by year,
Php calculates the number of days for different dates. Php calculates the number of days for different dates. This document describes how to calculate the number of days for different dates in php. Share it with you for your reference.
Php Tutorial date () convert mktime () to readable dateThe date/time function allows you to extract and format the date and time on the server.The mktime () function returns the unix timestamp of a date.The parameter always represents the gmt date,
Add date_default_timezone_set (PRC) to the front of the page ); /* Change the time to Beijing time. The default PhP5 time is Greenwich Mean Time. */ Date () : "Am" or "PM" A : "Am" or "PM" D : Day (s), double-digit characters. If not, zeros are
I. js date operations: Remember: all date strings use '/' as separators. Of course, '-' can be used as separators, however, using '/' can avoid unexpected errors.
1. method for obtaining time (I .e. constructor ):
①: Var myDate = new Date ()②: Var
Merge PHP computing hours to zero
CopyCode The Code is as follows:/* Author: Yang Yu yangyu@sina.cn */
// The $ hours_min parameter is an array. The array format is and the return value is 1 hour.
/*
For example:
$ Hours_min [0] = '1: 10 ';
$ Hours_
Number of days of the week in a loop (the red letter shows the number of days of the week)$ Week_array = array (1, 2, 3, 4, 5, 6, 7 );Foreach ($ week_array as $ key => $ value){If ($ value = date ("W "))$ Value = "". $ value. " ";Echo$ Value ."";}
The date and time in PHP are mainly obtained and formatted by the date () function. Although this is frequently used, it is sometimes forgotten or mixed, the summary is as follows...1. year/month/day 1. Year
Y (2010): uppercase y indicates four
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.