First, add the basics:varMyDate =NewDate (); MyDate default returns the current time Mydate.getyear (); //get Current year (2-bit)Mydate.getfullyear ();//Get the full year (4-bit, 1970-????)Mydate.getmonth ();//Get the current month (0-11, 0 for January)Mydate.getdate ();//get current day (1-31)Mydate.getday ();//get Current week x (0-6, 0 for Sunday)Mydate.gettime ();//Gets the current time (the number of milliseconds since 1970.1.1)Mydate.gethours ();//gets the current number of hours (
The following is an example, modified according to the actual situation--The following is the format of the date timeEXPDP Ha_soar/[email protected] Schemas=wyzj directory=data_pump_dir dumpfile=wyzj%date:~0,4%%date:~5,2%%date:~8,2% %time:~0,2%%time:~3,2%.dmp Logfile=wyzj%date
).ToShortDateString ();
Last year, no more explaining.
DateTime.Parse (DateTime.Now.ToString ("yyyy-01-01")). AddYears (-1).ToShortDateString ();
DateTime.Parse (DateTime.Now.ToString ("yyyy-01-01")). AddDays (-1).ToShortDateString ();
Next year
DateTime.Parse (DateTime.Now.ToString ("yyyy-01-01")). AddYears (1).ToShortDateString ();
DateTime.Parse (DateTime.Now.ToString ("yyyy-01-01")). AddYears (2). AddDays (-1).ToShortDateString ();
This quarter, many people will feel th
1, first through Strtotime () to obtain the date timestamp
2, get the time stamp N days ago, through the "current timestamp-n days of the number of seconds = n days before the time stamp"
3, to n days before the time stamp with the date () function for format conversion
The following example: Date of the day before the 2012-5-1 number was obtained
Copy the Code
DateTime classes also support the addition and subtraction of Timedelta.datetime1 = datetime2 +/-= Datetime1-datetime2In this way, it is convenient to implement some functions.1. The number of days between two dates.D1 = datetime.datetime.strptime ('2012-03-05 17:41:20'%y-%m-%d%h:%m:%s '= datetime.datetime.strptime ('2012-03-02 17:41:20' %y-%m-%d%h:%m:%s'= d1- d2print delta.daysOutput: 32. Today's date of N days.now == Datetime.timedelta (days=3= n
Tag: operation represents data ptime datetime tuple value type tar plus subtractionSome operations on the date:Some operations on the date: 1 #日期转化为字符串并得到指定 (or system date) n days after the date [emailprotected] 2 def datatimetostring (Dsnow=reservationtime (). Get (" Workerdate "), Dsdays=1): 3" "" 4:p Aram Dsno
Converts a string into a dateSimpleDateFormat re = new SimpleDateFormat (String formate);----: YYYY-MM-DDSystem.out.println (Re.parse ("1990-02-02"));----Fri Feb 00:00:00 CST 1990Convert Date to StringSimpleDateFormat sfdate = new SimpleDateFormat (String formate);----: YYYY-MM-DDSystem.out.println (Sfdate.format (New Date ()));-----2015-09-24Get Current time information:Calendar CA = Calendar.getinstance (
First, on the code1var diffdate =function(date, diff) {2 return NewDate (3 DATE.UTC (4 date.getutcfullyear (),5 date.getutcmonth (),6 date.getutcdate (),7 date.getutchours (),8 date.getutcminutes (),9 date.getutcseconds ()Ten) + One diff A ); -};Second, the upper principle1 The total number of milliseconds to convert the date () object to the UTC standard Time2 The number of
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 daysfunction GetData ($writetime, $limit) {$start _unix = Strtotime ($start); for ($i = 0; $i About the visualization of the statistical database, we have been looking for ways to use the background calculation, filtering data
Time turns into years, days and secondsSelect Date_format (now (), '%y%m%d%h%i%s ')Time turns into month and daySelect Date_format (now (), '%y%m%d ')This time last yearSelect Date_add (now (), Interval-1 year)This time last monthSelect Date_add (now (), Interval-1 month)Yesterday at this timeSelect Date_add (now (), Interval-1 Day)After 7 daysSelect Date_add (now (), Interval 7 day)//an hour ago Select Date_add (now (), INTERVAL-1 Hour) //One minute ago Select Date_add (now (), Interval-1 min
Tags: mysql date pos sel mic Art MYSQ class ... TimeAdd three days to the current date and change the number of days:SELECT Date_add (Current_date (), Interval 3 day);Add three days to the specified date:SELECT date_add (' 2014-04-17 ', Interval 3 day);-2014-04-20Add a time to the specified time:As in "January 1, 2012 two o'clock" plus Sparing 10 seconds MySQL st
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.