time()在PHP中是得到一个数字,这个数字表示从1970-01-01到现在共走了多少秒,很奇怪吧 不过这样方便计算, 要找出前一天的时间就是 time()-60*60*24; 要找出前一年的时间就是 time()*60*60*24*365 那么如何把这个数字换成日期格式呢,就要用到date函数了 $t=time(); echo date("Y-m-d H:i:s",$t); 第一个参数的格式分别表示: a - "am" 或是 "pm" A - "AM" 或是 "PM" d - 几日,二位数字,若不足二位则前面补零; 如...
最近偶为了写一个调整时间的shell而绞尽脑汁,结果在某一天 #info data 这里面看到了data -d参数的灵活用法,真是欣喜若狂。好东西要保存,整理整理: * To print the date of the day before yesterday: date --date='2 days ago' * To print the date of the day three months and one day hence: date --date='3 months 1 day' * To print the day of year of Christmas in the current year: ...
date 命令参数小技巧 LastUpdated:2006-03-27 By:Gman! -for beginner:wink: 此参数可以用于日志处理和时间统计; 由于Linux对man date -d 参数说的比较模糊,故举例如下: # -d, --date=STRING display time described by STRING, not `now' For Linux [root@Gman root]# date -d next-day +%Y%m%d 20060328 [root@Gman root]# date -d last-day +%Y%m%d 20060326 [root@Gman root]# date -d yesterday +%Y%m%d 2...
date 命令参数小技巧 LastUpdated:2006-03-27 By:Gman! -for beginner:wink: 此参数可以用于日志处理和时间统计; 由于Linux对man date -d 参数说的比较模糊,故举例如下: # -d, --date=STRING display time described by STRING, not `now' For Linux [root@Gman root]# date -d next-day +%Y%m%d 20060328 [root@Gman root]# date -d last-day +%Y%m%d 20060326 [root@Gman root]# date -d yesterday +%Y%m%d 2...
PHP 中date()函数有关参数 在页面的最前页加上 date_default_timezone_set(PRC); /*把时间调到北京时间,php5默认为格林威治标准时间*/ date () a: "am"或是"pm" A: "AM"或是"PM" d: 几日,两位数字,若不足则补零;从"01"至"31" D: 星期几,3个英文字母,如:"Fri" F: 月份,英文全名,如:"January" h: 12小时制的小时,从"01"至"12" H: 24小时制的小时,从"00"至"23" g: 12小时制的小时,不补...
他接受错误的日期 [root@localhost server]# date -d '2003-12-54' Fri Jan 23 00:00:00 CST 2004 但不接受错误的时间 [root@localhost server]# date -d '2003-12-12 7:00:00' Fri Dec 12 07:00:00 CST 2003 [root@localhost server]# date -d '2003-12-12 27:00:00' date: invalid date `2003-12-12 27:00:00' 我的本意是要把给定的一个时间(不是now)转换成别的时区,找到这个参数时有点兴奋,以为可以用date --date='8 hour ago'...
作者: ysgyggs 出自: http://www.linuxdiyf.com ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,内容如下: # The primary network interface auto eth0 iface eth0 inet dhcp 设置静态ip的方法如下: 1) 编辑 /etc/network/interfaces 1.1)将dhcp 一行屏蔽 # The primary network interface auto eth0 #iface eth0 inet dhcp 1.2)添加和静态ip有关的参数 # The primary network interface iface ...
问题是这样的,linux上date命令有如下格式化方式 昨天 (前一天) ■date --date='1 days ago' "+%Y-%m-%d" ■date -d '1 days ago' "+%Y-%m-%d" ■date -d yesterday "+%Y-%m-%d" 明天 (後一天) ■date --date='1 days' "+%Y-%m-%d" ■date -d '1 days' "+%Y-%m-%d" ■date -d tomorrow "+%Y-%m-%d" 1小時前 ■date --date='1 hours ago' "+%Y-%m-%d %H:%M:%S" 1小時後 ■date --date='1 hours' "+%Y-%m-%d %H:%M:%S" 1分鐘前 ■...
date -r 秒数 (从1970 0:0:0算起的秒数) 可以把时间从秒数转换为时间, 那我现在要把类似于 20050808120000(2005,8月8日12点0分0秒)的时间转化为从1970年0点0分0秒到现在的秒数 该用那个参数?