When you use the -r option, the date command prints the last modification time of a file. For example, the following command prints the last time the hosts file was changed:. To use a different time zone in the environment, set the TZ variable to the desired time zone.
Type in the date command to return the system to its default time zone. To see all available time zones, use the timedatectl list-timezones command. The date command can also show the local time for a different time zone. For example, to display the local time for PM next Monday on the Australian east coast, type:. You can use the date command to create file names that contain the current time and date. The input below creates a backup MySQL file in the format of the current date:.
Another common use of the date command is in shell scripts. You can use the date command as an Epoch converter. Epoch, or Unix timestamps, is the number of seconds that have passed since January 1, , at UTC.
Displays a list of a directory's files and subdirectories. If used without parameters, this command displays the disk's volume label and serial number, followed by a list of directories and files on the disk including their names and the date and time each was last modified. For files, this command displays the name extension and the size in bytes. This command also displays the total number of files and directories listed, their cumulative size, and the free space in bytes remaining on the disk.
The dir command can also run from the Windows Recovery Console, using different parameters. This is the default behavior. Displays help at the command prompt. Remarks To use multiple filename parameters, separate each file name with a space, comma, or semicolon. The asterisk wildcard always uses short file name mapping, so you might get unexpected results.
For example, the following directory contains two files t. You can use the question mark? For example, typing dir read???. This includes Read. If you specify more than one sortorder value, this command sorts the file names by the first criterion, then by the second criterion, and so on. If by chance, I did not boot my computer for 15 days, the day-count subtraction will be negative, and I will run my job, and then set the day-count to 11 past today. Have a question or suggestion? Please leave a comment to start the discussion.
Please keep in mind that all comments are moderated and your email address will NOT be published. Save my name, email, and website in this browser for the next time I comment. Notify me of followup comments via e-mail. You can also subscribe without commenting. This site uses Akismet to reduce spam. Other specifiers produce a NULL value or 0.
The other hour format specifiers produce the hour value modulo Returns the time argument, converted to seconds. Given a date date , returns a day number the number of days since year 0.
For dates before and possibly a later year in other locales , results from this function are not reliable. Remember that MySQL converts two-digit year values in dates to four-digit form using the rules in Section For example, '' and '' are seen as identical dates:. In MySQL, the zero date is defined as '' , even though this date is itself considered invalid.
Given a date or datetime expr , returns the number of seconds since the year 0. If expr is not a valid date or datetime value, returns NULL. The server interprets date as a value in the session time zone and converts it to an internal Unix timestamp value in UTC. If the argument includes a time part, it may optionally include a fractional seconds part. The return value is an integer if no argument is given or the argument does not include a fractional seconds part, or DECIMAL if an argument is given that includes a fractional seconds part.
Prior to MySQL 8. This is also the case in MySQL 8. For MySQL 8. Here is an example, using values that are distinct in the MET time zone:. Returns the current UTC time as a value in 'hh:mm:ss' or hhmmss format, depending on whether the function is used in string or numeric context.
WEEK date [, mode ]. This function returns the week number for date. The two-argument form of WEEK enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to The following table describes how the mode argument works.
If the week containing January 1 has 4 or more days in the new year, it is week 1. Otherwise, it is the last week of the previous year, and the next week is week 1.
If a date falls in the last week of the previous year, MySQL returns 0 if you do not use 2 , 3 , 6 , or 7 as the optional mode argument:. One might argue that WEEK should return 52 because the given date actually occurs in the 52nd week of If you prefer a result evaluated with respect to the year that contains the first day of the week for the given date, use 0 , 2 , 5 , or 7 as the optional mode argument.
Returns the calendar week of the date as a number in the range from 1 to YEAR date. Returns year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year. The mode argument works exactly like the mode argument to WEEK. For the single-argument syntax, a mode value of 0 is used. The week number is different from what the WEEK function would return 0 for optional arguments 0 or 1 , as WEEK then returns the week in the context of the given year.
Built-In Function and Operator Reference. Loadable Function Reference. Type Conversion in Expression Evaluation. Comparison Functions and Operators. Numeric Functions and Operators. Date and Time Functions. String Functions and Operators. String Comparison Functions and Operators. Character Set and Collation of Function Results.
Natural Language Full-Text Searches.
0コメント