亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
1234下一頁
最近訪問板塊 發(fā)新帖
查看: 23814 | 回復: 36
打印 上一主題 下一主題

如何用date獲得前一天的日期,忘了  關閉 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2002-04-02 09:55 |只看該作者 |倒序瀏覽
好象有date 有-24 有+%y%m%d等,謝了。
還有有辦法獲得3天前的日期嗎?

論壇徽章:
0
2 [報告]
發(fā)表于 2002-04-02 10:18 |只看該作者

如何用date獲得前一天的日期,忘了

唉,在b shell沒有這個用法了,要想用純shell做幾天前后的運算,只有自己想辦法了,+%y%m%d用于控制輸出格式,作用有限,要想做的話,參見這個帖子大家的發(fā)言:
http://www.chinaunix.net/cgi-bin/bbs/topic.cgi?forum=11&topic=91&show=30

論壇徽章:
0
3 [報告]
發(fā)表于 2002-04-02 10:28 |只看該作者

如何用date獲得前一天的日期,忘了

我的確在哪兒看到用一條命令就可以取昨天或明天的日期,
參數(shù)中有-24或+24。沒那么復雜

論壇徽章:
0
4 [報告]
發(fā)表于 2002-04-02 10:52 |只看該作者

如何用date獲得前一天的日期,忘了

好象用到了參數(shù)TZ=-24;export TZ什么的

論壇徽章:
0
5 [報告]
發(fā)表于 2002-04-02 11:03 |只看該作者

如何用date獲得前一天的日期,忘了

改變時區(qū),應該可以實現(xiàn),確實是個好方法。

論壇徽章:
0
6 [報告]
發(fā)表于 2002-04-02 12:28 |只看該作者

如何用date獲得前一天的日期,忘了

可現(xiàn)在我卻實現(xiàn)不了?

論壇徽章:
0
7 [報告]
發(fā)表于 2002-04-02 16:09 |只看該作者

如何用date獲得前一天的日期,忘了

不會吧,你說的俺都明白了,你自己還不懂?

date命令的顯示是與環(huán)境變量TZ有關的
看以下的命令操作,你應該便明白了,

$#看當前時區(qū)
$echo $TZ
CST-8
$#顯示當前時間
$date
Mon Apr  2 15:48:36 CST 2002
$#改變當前時區(qū),
TZ=CST+16;export TZ
$#顯示當前時間(中間未改變系統(tǒng)時間,但date命令的顯示已為昨天)
Mon Apr  1 15:48:33 CST 2002

論壇徽章:
0
8 [報告]
發(fā)表于 2002-04-03 08:57 |只看該作者

如何用date獲得前一天的日期,忘了

是啊,我已經(jīng)明白了,忘了告訴斑竹一聲
wolfer 該用戶已被刪除
9 [報告]
發(fā)表于 2002-04-03 09:52 |只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽

論壇徽章:
0
10 [報告]
發(fā)表于 2002-06-20 14:24 |只看該作者

如何用date獲得前一天的日期,忘了

#!/bin/sh

# ydate: A Bourne shell script that
# prints yestarday's date
# Output Form: Month Day Year
# From Focus on Unix: http://unix.about.com

# Set the current month day and year.
month=`date +%m`
day=`date +%d`
year=`date +%Y`

# Add 0 to month. This is a
# trick to make month an unpadded integer.
month=`expr $month + 0`

# Subtract one from the current day.
day=`expr $day - 1`

# If the day is 0 then determine the last
# day of the previous month.
if [ $day -eq 0 ]; then
  
  # Find the preivous month.
  month=`expr $month - 1`  

  # If the month is 0 then it is Dec 31 of
  # the previous year.
  if [ $month -eq 0 ]; then
    month=12
    day=31
    year=`expr $year - 1`  

  # If the month is not zero we need to find
  # the last day of the month.
  else
    case $month in
      1|3|5|7|8|10|12) day=31;;
      4|6|9|11) day=30;;
      2)
        if [ `expr $year % 4` -eq 0 ]; then
          if [ `expr $year % 400` -eq 0 ]; then
            day=29
          elif [ `expr $year % 100` -eq 0 ]; then
            day=28
          else
            day=29
          fi
        else
          day=28
        fi
      ;;
    esac
  fi
fi

# Print the month day and year.
echo $month $day $year
exit 0
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP