Date: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
|||
Line 13: | Line 13: | ||
$date "+%d.%m.%y" | $date "+%d.%m.%y" | ||
Tulemus: 19.03.11 | Tulemus: 19.03.11 | ||
=Parameetrid= | |||
{|class="wikitable" | |||
|+Format specifiers (format string starts with '''+''') | |||
! Specifier | |||
! Description | |||
! width="150"| Values/Example | |||
|- | |||
!colspan=3| Day | |||
|- | |||
| '''%a''' ||weekday, abbreviated || {{#time: D}} | |||
|- | |||
| '''%A''' ||weekday, full || {{CURRENTDAYNAME}} | |||
|- | |||
|| '''%d''' ||day of the month (dd), zero padded || {{CURRENTDAY2}} | |||
|- | |||
| '''%e''' ||day of the month (dd) || {{CURRENTDAY}} | |||
|- | |||
| '''%j''' ||day of year, zero padded || 001-366 | |||
|- | |||
| '''%u''' ||day of week starting with Monday (1), i.e. mtwtfss || {{#time: N}} | |||
|- | |||
| '''%w''' ||day of week starting with Sunday (0), i.e. smtwtfs || {{#time: w}} | |||
|- | |||
!colspan=3| Week | |||
|- | |||
| '''%U''' ||week number Sunday as first day of week ||01–53 | |||
|- | |||
| '''%W''' ||week number Monday as first day of week ||01–53 | |||
|- | |||
| '''%V''' ||week of the year ||01–53 | |||
|- | |||
!colspan=3| Month | |||
|- | |||
|'''%m''' ||mm month ||{{CURRENTMONTH}} | |||
|- | |||
|'''%h''' ||Mon ||{{CURRENTMONTHABBREV}} | |||
|- | |||
|'''%b''' ||Mon, locale's abbreviated || {{CURRENTMONTHABBREV}} | |||
|- | |||
|'''%B''' ||locale's full month, variable length || {{CURRENTMONTHNAME}} | |||
|- | |||
!colspan=3| Year | |||
|- | |||
| '''%y''' ||yy two digit year ||00–99 | |||
|- | |||
| '''%Y''' ||ccyy year ||{{#time: Y}} | |||
|- | |||
| '''%g''' ||2-digit year corresponding to the %V week number || | |||
|- | |||
| '''%G''' ||4-digit year corresponding to the %V week number || | |||
|- | |||
!colspan=3| Century | |||
|- | |||
| '''%C''' ||cc century ||00–99 | |||
|- | |||
!colspan=3| Date | |||
|- | |||
| '''%D''' ||mm/dd/yy || {{CURRENTMONTH}}/{{CURRENTDAY}}/{{#time: y}} | |||
|- | |||
| '''%x''' ||locale's date representation (mm/dd/yy) || {{CURRENTMONTH}}/{{CURRENTDAY}}/{{CURRENTYEAR}} | |||
|- | |||
| '''%F''' ||%Y-%m-%d || {{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY}} | |||
|- | |||
!colspan=3| Hours | |||
|- | |||
| '''%l''' ''(Lowercase L)'' ||hour (12 hour clock) ||{{#time: g}} | |||
|- | |||
| '''%I''' ''(Uppercase I)'' ||hour (12 hour clock) zero padded ||{{#time: h}} | |||
|- | |||
| '''%k''' ||hour (24 hour clock) ||{{#time: G}} | |||
|- | |||
| '''%H''' ||hour (24 hour clock) zero padded ||{{#time: H}} | |||
|- | |||
|'''%p''' ||locale's upper case AM or PM (blank in many locales) || {{#time: A}} | |||
|- | |||
| '''%P''' ||locale's lower case am or pm || {{#time: a}} | |||
|- | |||
!colspan=3| Minutes | |||
|- | |||
| '''%M''' ||MM minutes ||{{#time: i}} | |||
|- | |||
!colspan=3| Seconds | |||
|- | |||
| '''%s''' ||seconds since 00:00:00 1970-01-01 UTC ([[Unix epoch]]) ||{{#time: U}} | |||
|- | |||
| '''%S''' ||SS second ||00–60<br /><small>(The 60 is necessary to accommodate a leap second)</small> | |||
|- | |||
| '''%N''' ||nanoseconds ||000000000–999999999 | |||
|- | |||
!colspan=3| Time | |||
|- | |||
| '''%r''' ||hours, minutes, seconds (12-hour clock) || {{#time: h:i:s A}} | |||
|- | |||
| '''%R''' ||hours, minutes (24 hour clock) || hh:mm e.g. {{CURRENTTIME}} | |||
|- | |||
| '''%T''' ||hours, minutes, seconds (24-hour clock) || {{#time: H:i:s}} | |||
|- | |||
| '''%X''' ||locale's time representation (%H:%M:%S) | |||
|- | |||
!colspan=3| Date and Time | |||
|- | |||
| '''%c''' ||locale's date and time ||Sat Nov 04 12:02:33 EST 1989 | |||
|- | |||
!colspan=3| Time zone | |||
|- | |||
| '''%z''' ||-zzzz RFC-822 style numeric timezone || -0500 | |||
|- | |||
| '''%Z''' ||time zone (e.g., EDT) nothing if no time zone is determinable || EST | |||
|} |
Revision as of 12:12, 1 May 2011
Teema on valmimisel
Sissejuhatus
Date - käsuga saab masinalt küsida kellaaega ja kuupäeva. Administraator saab date käsu abil ka kuupäeva ja kellaaega muuta.
Date käsu kasutamine
Lihtsalt date käsk väljastab standard kujul aja: Päev Kuu Kuupäev kellaeg ajatsoon aasta
$date Tulemus: Sat Mar 19 15:22:48 EET 2011
Date käsu küsimine kindlate parameetritega
Date käsuga saab küsida masinalt soovitavat aega sobival kujul. $date käsule tuleb lisada string mis jääb " " vahele ja algab + märgiga. Parameetreid küsitakse kujul %esimene parameeter %teine parameeter. Parameetrite vahele saab valida eraldajaid.
Parameetritega käsu näide: küsitakse %päeva %kuud %aastat ja eraldajateks on . märgid $date "+%d.%m.%y" Tulemus: 19.03.11
Parameetrid
Specifier | Description | Values/Example |
---|---|---|
Day | ||
%a | weekday, abbreviated | {{#time: D}} |
%A | weekday, full | Sunday |
%d | day of the month (dd), zero padded | 24 |
%e | day of the month (dd) | 24 |
%j | day of year, zero padded | 001-366 |
%u | day of week starting with Monday (1), i.e. mtwtfss | {{#time: N}} |
%w | day of week starting with Sunday (0), i.e. smtwtfs | {{#time: w}} |
Week | ||
%U | week number Sunday as first day of week | 01–53 |
%W | week number Monday as first day of week | 01–53 |
%V | week of the year | 01–53 |
Month | ||
%m | mm month | 11 |
%h | Mon | Nov |
%b | Mon, locale's abbreviated | Nov |
%B | locale's full month, variable length | November |
Year | ||
%y | yy two digit year | 00–99 |
%Y | ccyy year | {{#time: Y}} |
%g | 2-digit year corresponding to the %V week number | |
%G | 4-digit year corresponding to the %V week number | |
Century | ||
%C | cc century | 00–99 |
Date | ||
%D | mm/dd/yy | 11/24/{{#time: y}} |
%x | locale's date representation (mm/dd/yy) | 11/24/2024 |
%F | %Y-%m-%d | 2024-11-24 |
Hours | ||
%l (Lowercase L) | hour (12 hour clock) | {{#time: g}} |
%I (Uppercase I) | hour (12 hour clock) zero padded | {{#time: h}} |
%k | hour (24 hour clock) | {{#time: G}} |
%H | hour (24 hour clock) zero padded | {{#time: H}} |
%p | locale's upper case AM or PM (blank in many locales) | {{#time: A}} |
%P | locale's lower case am or pm | {{#time: a}} |
Minutes | ||
%M | MM minutes | {{#time: i}} |
Seconds | ||
%s | seconds since 00:00:00 1970-01-01 UTC (Unix epoch) | {{#time: U}} |
%S | SS second | 00–60 (The 60 is necessary to accommodate a leap second) |
%N | nanoseconds | 000000000–999999999 |
Time | ||
%r | hours, minutes, seconds (12-hour clock) | {{#time: h:i:s A}} |
%R | hours, minutes (24 hour clock) | hh:mm e.g. 01:24 |
%T | hours, minutes, seconds (24-hour clock) | {{#time: H:i:s}} |
%X | locale's time representation (%H:%M:%S) | |
Date and Time | ||
%c | locale's date and time | Sat Nov 04 12:02:33 EST 1989 |
Time zone | ||
%z | -zzzz RFC-822 style numeric timezone | -0500 |
%Z | time zone (e.g., EDT) nothing if no time zone is determinable | EST |