如何在Solaris上的日期中减去或增加几天或几个月? [英] How to subtract or add days or months to a date on Solaris?

查看:99
本文介绍了如何在Solaris上的日期中减去或增加几天或几个月?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Linux date 具有 -d 功能,在Solaris中缺少。因此,我该如何在Solaris上的日期中减去或增加几天或几个月。

Linux date has the -d feature which is missing in Solaris. So how can I go about subtracting or adding days or months to a date on Solaris.

推荐答案

您仍然可以使用perl进行此操作或python oneliners,例如,从当前日期减去一天:

you still can do this with perl or python oneliners, e.g., substract one day from current date:

$ date
Thu May 14 15:31:49 MEST 2015
$ python -c "from datetime import datetime, timedelta; print (datetime.now() - timedelta(1)).strftime('%c');"
Wed May 13 15:31:58 2015

这篇关于如何在Solaris上的日期中减去或增加几天或几个月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆