date命令的两种常用法

Linux常用命令之date命令详解 date 命令是 Linux 系统中用于显示或设置系统日期与时间的一个强大工具。它不仅能够以多种格式输出当前的时间信息,还可以用来执行一些与时间相关的计算和转换。 阅读详情

本文首发于我的Github博客

本文记录了作者在平时工作中经常用到的Linux命令date的两种常见使用方式,简单来说:

  1. 打印当前时间,date "+<output_format>"
  2. 将Unix时间戳转化为可读的日期+时间date -r <unix-timestamp> "+<output_format>"

打印当前时间

只需要使用date "+<output_format>"就可以打印当前时间,其中,output_format由正常字符和转义字符组成,转义字符用来打印当前的年,月,日等等

转义字符含义
%Y年
%m月
%d日
%H小时
%M分钟
%S秒
%s时间戳

例如

> date "+%Y-%m-%d-%H-%M-%S"
2020-06-01-11-24-39

将Unix时间戳转化为可读的日期+时间

使用date -r <unix-timestamp> "+<output_format>"即可完成转化,其中的output_format和上文中介绍的一样,<unix-timestamp就是一个数字

例如

> date -r 0 "+%Y-%m-%d-%H-%M-%S"
1970-01-01-08-00-00
AI科技热点日报 | 2026年11月12日 今天窗口内,AI 产业的重心从"拼参数"转向"拼落地、拼合规、拼治理"。产品侧最密集的是三件事:谷歌把此前只为网络安全团队保留的旗舰模型 Gemini 4 Carbon 正式全面开放,API 首发价每百万输入 Token 2 美元、输出 10 美元,11 月 30 日后翻倍至 4 美元与 20 美元,官方称其在 Artificial Analysis 智能指数 v5.0 上以 59 分排名第一; 阅读详情

相关推荐

Typora绘制思维导图

我们观察一下,其实思维导图就是树状结构的数据嘛,作为程序员,拿语言写树状结构的数据是很平常的事情。而且写代码可比画图省事多了,查阅资料可以知道,有一种`mermaid`语法,就是做这件事情的,支持 UML,甘特图,流程图等。

Peter Cheung的博客 7941

Linux基础命令-date命令

Linux-date命令用法

老司机开代码的博客 2万+

AI智能体协作:构建更精准的公司破产预测模型

公司破产预测对于金融机构、投资者和监管部门等具有至关重要的意义。准确的破产预测可以帮助金融机构提前做好风险防范,避免贷款损失;投资者可以根据预测结果调整投资组合,降低投资风险;监管部门可以及时发现潜在的金融风险,采取相应的监管措施。然而,传统的公司破产预测模型往往存在精度不高的问题,无法满足实际需求。本研究的目的是利用AI智能体协作的方式,构建一个更精准的公司破产预测模型。通过将多个AI智能体的优势进行整合,充分挖掘公司财务数据、市场数据等多源数据中的信息,提高预测的准确性和可靠性。

2501_92132293的博客 1087

ubuntu date -R查看时区

学亮编程手记 5176

72、海洋地理信息系统:电子海图的全面解析

本文全面解析了海洋地理信息系统中的电子海图技术,从AIS数据的应用、电子海图数据的存储与显示,到电子导航的发展趋势和S-100通用水文数据模型的推广,系统地阐述了电子海图在现代航海中的核心作用及其未来发展方向。

hhh00的博客 260

元学习与Transformer的结合:Meta-Transformer架构解析

我们生活在一个信息爆炸的时代,每天都会产生海量的数据。在深度学习领域,如何让模型更高效地学习、更快地适应新的任务,一直是科学家们努力的方向。元学习和Transformer都是深度学习中的重要概念,它们各自有着独特的优势。本文的目的就是深入剖析将元学习和Transformer结合起来的Meta - Transformer架构,探讨它的原理、应用以及未来发展。我们会从基础概念讲起,逐步深入到架构的各个方面,让大家对Meta - Transformer有一个全面的了解。

AI智能探索者的博客 1057

linux之date命令

date 命令用于系统的时间或日期。date [参数] [+日期格式]date后面有一个空格,否则无法识别命令,shell对空格是很严格的。

weixin_40482816的博客 1899

工业级稳定!C# 实现 Modbus RTU 多设备并发通信实战

摘要:本文提出一种基于C#的Modbus RTU多设备并发通信方案,解决工业自动化中单线程通信的串口抢占、数据阻塞等问题。采用任务队列+线程安全锁+异步调度的三层架构,实现16台及以上RTU设备的稳定并发读写。方案包含串口管理单例、Modbus通信核心和任务调度层,支持超时重试、异常捕获等工业级容错机制。通过NModbus库和.NET框架,提供可直接用于工业现场的代码实现,已在工控项目中长期验证,有效提升多设备通信效率和稳定性。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 586

Ubuntu 常用命令之 date 命令用法介绍

文章解释并演示了ubuntu系统下,命令 date 的用法

dyy123 2010

Windows原生与WSL2环境下OpenClaw性能与兼容性的对比分析研究

本文对比分析了Windows原生环境与WSL2环境下运行OpenClaw的性能与兼容性。Windows原生环境提供深度系统集成、图形界面支持和硬件加速优势,适合需要Windows生态集成的用户;WSL2则提供接近原生Linux的性能体验,兼容Linux工具链,适合开发者和跨平台需求。文章详细介绍了两种环境下的推荐硬件配置、系统版本选择及必备工具,并提供了具体的部署步骤指南。研究表明,两种环境各有适用场景,用户可根据需求选择最适合的部署方式。

一键难忘的博客 1226

SEATA安装使用

springcloudalibaba集成seata分布式事务、seata持久化

原名又逢乱世。不要放下学习的脚步,毕竟比天天打牌、钓鱼、打游戏更能从内在充实自己。 2376

Linux基础命令- date

Linux基础命令- date

m0_67159981的博客 2694

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Linux命令之date命令

Linux date命令可以用来显示或设定系统的日期与时间。在显示方面使用者可以设定欲显示的格式,格式设定为一个加号后接数个标记。在备份文件的时候我们常结合此命令生成当前日期和时间的文件名。格式符前面以+加号开头,若是不以加号作为开头,则表示要设定时间,而时间格式为 MMDDhhmm[[CC]YY][.ss],其中 MM 为月份,DD 为日,hh 为小时,mm 为分钟,CC 为年份前两位数字,YY 为年份后两位数字,ss 为秒数。

月生的静心苑 4万+

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Shell中常用的date时间命令

date时间的常用命令 echo `date -d' +1 hours' +%Y%m%d` 剩下的待周末回家完善

大宇进阶之路的博客 8506

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Linux系统之date命令的基本使用

Linux系统之date命令的基本使用

jks212454的博客 2643

linux中date命令详解,linux中date命令的详细解释

在linux系统下编程难免会遇到处理时间的问题,掌握date命令能让我们在实际应用中更加方便。下面由学习啦小编整理了linux的date命令的详细解释,希望对你有帮助。linux的date命令的详细解释1.命令格式:date [参数]... [+格式]2.命令功能:date 可以用来显示或设定系统的日期与时间。3.命令参数:必要参数:%H 小时(以00-23来表示)。%I 小时(以01-12来表示...

weixin_42131013的博客 5246

date命令

在linux环境中,不管是编程还是其他维护,时间是必不可少的,也经常会用到时间的运算,熟练运用date命令来表示自己想要表示的时间,肯定可以给自己的工作带来诸多方便。

unber的博客 1196

date 命令学习

在显示方面使用者可以设定欲显示的格式,格式设定为一个加号后接数个标记。在备份文件的时候我们常结合此命令生成当前日期和时间的文件名。格式符前面以加号开头,若是不以加号作为开头,则表示要设定时间,而时间格式为,其中MM为月份,DD为日,hh为小时,mm为分钟,CC为年份前两位数字,YY为年份后两位数字,ss为秒数。ISO-8601 格式年份的最后两位 (参见%G)ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用242024显示指定文件的最后修改时间。

D的博客 1826

Linux date命令常用操作

date格式化输出用+号 如 [root@hadoop01 ~]# date +%Y-%m-%d 2019-02-22 date +%Y-%m-%d %H:%M:%S 会报错,需要用''单引号引起来 [root@hadoop01 ~]# date +%Y-%m-%d %H:%M:%S date: 额外的操作数 "%H:%M:%S" 请尝试执行"date --help"来获取更...

weixin_42496757的博客 2939

DOS命令之Date命令的用法

DATE命令的用法 1.系统帮助 C:>date /? 显示或设置日期。 DATE [/T | date] 仅键入 DATE 而不加参数,可以显示当前日期设置,并且提示 您输入新的日期。按 ENTER 键即可保持原有日期。 如果命令扩展名被启用,DATE 命令会支持 /T 命令选项;该命令选项告诉 命令只输出当前日期,但不提示输出新日期。 2.DATA /T 参数说明 此参数输

yixilan唠几句 2908

【学习笔记】Linux系统基础知识4 —— date命令详解

Linux系统基础命令 date 命令详解

qq_33216613的博客 8285

Shell中的date命令

date命令 在Linux环境中,不管是编程还是其他维护,时间是必不可少的,也经常会用到时间的运算,熟练运用date命令来表示自己想要表示的时间,肯定可以给自己的工作带来诸多的方便。 1. 命令格式: date [参数] [+格式] 2. 命令功能: date可以用来显示或设定系统的日期与时间。 3.命令参数: 必要参数: %H 小时(以00-23来表示)。 %I 小时(以00-12来表示)。 ...

weixin_44572041的博客 1万+

date命令详解

基础命令学习目录首页 原文链接:https://www.cnblogs.com/qmfsun/p/4598650.html date "+今天是%Y-%d-%m,现在是%H:%M:%S" 1. 显示时间date命令可以按照指定格式显示日期,只键入date则以默认格式显示当前时间。如下: 如果需要以指定的格式显示日期,可以使用“+”开头的字符串指定其格式,详细格式如下:%n : ...

weixin_34080951的博客 2540

Linux date 命令

1、概述          打印或者设置系统日期和时间   2、命令格式          date[OPTION]... [+FORMAT]          date[-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]   3、常用命令参数 [oldboy@zhang~]$ date Sun Dec 20 17:51:57 CST

踏歌行的专栏 5710

Linux命令之date命令详细讲解

Linux命令之date命令详细讲解

wumuzibabi的博客 7969
上一篇: git-status中文乱码问题
下一篇: 转义sed替换模式字符串
FitzLeopard
博客等级 码龄9年 6粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值