դ դ ĥ줿 date ޥGNU dateפѲǽʾ date -d '1 days ago' -d 'N days ago'פ N դǤ롣

Linux Ǥϳĥ줿 date ޥѤǤΤǡñ˲դǤ롣

$ date 2007ǯ 6 2 23:05:20 JST Τޤ޼¹Ԥɽ롣

$ date -d '1 days ago' 2007ǯ 6 1 23:05:31 JST 1ꤹȡ24ɽ롣GNU dateפѤǤʤ TZ=JST+15 date Ū˴Ķѿ TZ ѹ date ޥ¹Ԥ롣

Ť UNIX ޥʤɤǤϡGNU dateפѤǤʤ礬¿äĶǤϡŪ˥ॾѹ date ޥ¹Ԥ뤳Ȥǡդ뤳ȤǤ롣

͵: [UNIX]ä

$ echo $TZ JST-9 ǥեȤΥॾ

$ date Sun Jun 26 03:38:04 2005 date ޥ̤˼¹ԤȺա

$ TZ=JST+15 date Sat Jun 25 03:39:03 2005 Ķѿ TZ ѹ date ޥǤĤȺա

$ echo $TZ JST-9 ¹Ը⥿ॾϥǥեȤΤޤޡ Ūѿ

ޥ¹Ի TZ=JST+15 date +%m/%d/%Y Τ褦ƱԤѿԤȤǡޥФƤΤͭˤʤ褦ѿꤹ뤳ȤǤ롣ξϡ;(ߥ)ǶڤäƤϤʤ;(ߥ)Ƕڤϡ( TZ=JST+15; date +%m/%d/%Y ) Τ褦ˡ()()ǰϤɬפ롣

դ ĥ줿 date ޥGNU dateפѲǽʾ date -d '1 days' -d 'N days'פ N դǤ롣

Linux Ǥϳĥ줿 date ޥѤǤΤǡҤκդƱͤˡñ˲դǤ롣

GNU dateפѤǤʤ TZ=JST-33 date Ū˴Ķѿ TZ ѹ date ޥ¹Ԥ롣

GNU date ѤǤʤ⡢ҤκդƱͤˡĶѿ TZ Ūѹ뤳Ȥˤ뤳ȤǽǤ롣

դΥեޥåȤꤹ date '+եޥå' "+" ƬդγƾɽǥեޥåȤꤹ롣

եޥåȤλˤϡǯסַססֻסʬפʤɤɽüʽ񼰤Ѥ롣

1970/01/01 00:00:00 ηв %s ǯ(4) %Y ǯ(2) %y (0112) %m (JanDec) %b (JanuaryDecember) %B (0131) %d (131) ޤ2 %e (SunSat) %a (SundaySaturday) %A (06) 0 %w (0023) %H (0112) %I ( 023) ޤ2 %k ( 112) ޤ2 %l ʬ(0059) %M (0059) %S AM/PM %p am/pm %P %n

եޥåȤꤷɽˤϡʲΤ褦˥ѥ᡼ꤷ date ޥ¹Ԥ롣

եޥå ޥ yyyy/mm/dd date '+%Y/%m/%d' yyyy/mm/dd (Sun..Sat) date '+%Y/%m/%d(%a)' yy/mm/dd date '+%y/%m/%d' yyyy-mm-dd date '+%F' mm/dd/yy date '+%D' hh:mm (24) date '+%R' hh:mm:ss (24) date '+%T' hh:mm:ss AM|PM (12) date '+%r'

ºݤޥ¹ԤƤߤ롣¹Ԥ2005ǯ911118ʬǤ롣

$ date '+%Y/%m/%d' 2005/09/11

$ date '+%Y/%m/%d(%a)' 2005/09/11(Sun)

$ date '+%y/%m/%d' 05/09/11

$ date '+%F' 2005-09-11

$ date '+%D' 09/11/05

$ date '+%R' 01:18

$ date '+%T' 01:18:01

$ date '+%r' 01:18:06 AM

$ date '+%Y/%m/%d%n%r' 2005/09/11 01:18:27 AM %n Ѥ뤳ȤǡϤ˲Ԥޤ뤳ȤǤ롣¾ˤɽǤϤ뤬̾Ӥʤ餳ξΤߤǽʬǤ

ռα ʲGNU date ޥѲǽǤ뤳ȤȤ롣

̤դ ꤷʬβ̤롣

# 10 date -d '10 seconds ago'

# 10ø date -d '10 seconds'

# 10ʬ date -d '10 minutes ago'

# 10ʬ date -d '10 minutes'

# 10 date -d '10 hours ago'

# 10ָ date -d '10 hours'

# 10 date -d '10 days ago'

# 10 date -d '10 days'

# 10 date -d '10 months ago'

# 10 date -d '10 months'

# 10ǯ date -d '10 years ago'

# 10ǯ date -d '10 years'

# 嵭ޥϤ줾եޥåȤꤷƼ¹Ԥ뤳Ȥǽ date -d '12 hours ago' '+%Y-%m-%d [%H:%M:%S]'date ޥɽ򸽺ǤϤʤΤ褦˻ꤷ date ޥ¹Ԥ뤳ȤǤ롣

# 2006/01/01 12:13:14פȤޥ¹Ԥ date -d '2006/01/01 12:13:14'

# եޥåȤλǽ date -d '2006/01/01 12:13:14' '+%Y %m %d - %H %M %S' date ޥꤹȡǤϤʤꤷǷ̤ɽ롣

顢ꤷʬβ̤뤳ȤǤ롣

date -d '2006/01/01 12:13:14 1 months ago'

# եޥåȤλǽ date -d '2006/01/01 12:13:14 1 months ago' '+%Y %m %d - %H %M %S'դӤԤ եʤɤդ򡢤ɤ餬Ť⤷ϿդǤ뤫ӤϼΤ褦ˤ롣

date_comparison.sh

#/bin/bash

# 1970-01-01 00:00:00 ηвäѴ DATE_1=`date -d "$1" '+%s'` DATE_2=`date -d "$2" '+%s'`

# 2ĤդɽƤ echo "DATE 1: $1" echo "DATE 2: $2"

# 2ĤդӤ̤ɽ if [ $DATE_1 -eq $DATE_2 ]; then

 echo "ꤵ줿2ĤդƱǤ"

elif [ $DATE_1 -gt $DATE_2 ]; then

 echo "DATE 1 դǤ"

elif [ $DATE_1 -lt $DATE_2 ]; then

 echo "DATE 2 դǤ"

fi

exit 0Υ륹ץ date_comparison.sh μ¹Է̤ϡʲ̤Ȥʤ롣

$ ./date_comparison.sh "2006/01/01 00:00:00" "2006/01/01 00:00:00" DATE 1: 2006/01/01 00:00:00 DATE 2: 2006/01/01 00:00:00 ꤵ줿2ĤդƱǤ

$ ./date_comparison.sh "2006/01/01 00:00:01" "2006/01/01 00:00:00" DATE 1: 2006/01/01 00:00:01 DATE 2: 2006/01/01 00:00:00 DATE 1 դǤ

$ ./date_comparison.sh "2006/01/01 00:00:00" "2006/01/01 00:00:01" DATE 1: 2006/01/01 00:00:00 DATE 2: 2006/01/01 00:00:01 DATE 2 դǤդ date ޥΥեޥåȻ '+%s' Ѥ뤳Ȥˤꡢ1970-01-01 00:00:00פηвäѴ롣ˤäơդӤñʿͤӤȤ뤳ȤǤ롣ĤޤäѴƤΤǡդ礭ͤȤȤˤʤ롣

ʤߤˡ'+%s' Ѥ date ޥμ¹Է̤ϰʲΤ褦ˤʤ롣

$ date -d '2006/01/01 00:00:00' '+%s' 1136041200

$ date -d '2006/01/01 00:00:01' '+%s' 1136041201


ȥå   Խ ʬ ʎގ̎ ź ʣ ̾ѹ   ǽ   إ   ǽRSS
Last-modified: 2008-02-01 () 19:42:34 (3883d)