草庐IT

invoice_date

全部标签

c - 如何在 char 数组中获取 `date` 命令的输出?

我想把GNU/Linuxdate命令的输出放在一个字符数组中。例子:chararray[25];$dateThuJul1909:21:31IST2012printf("%s",array);/*Shoulddisplay"ThuJul1909:21:31IST2012"*/我试过这个:#include#include#defineSIZE50intmain(){chararray[SIZE];sprintf(array,"%s",system("date"));printf("\nGotthis:%s\n",array);return0;}但输出显示数组中的NULL。

linux - 从 systemd bash 内联脚本创建 filename_$(date %Y-%m-%d)

我正在尝试执行一个systemd计时器,并希望将执行脚本的输出按日期保存在一个文件中。这是我在.service文件中的ExecStart脚本:ExecStart=/bin/bash-c'echo$(date+%Y-%m-%d)>>/home/username/test_output_$(date+%Y-%m-%d).log'这会创建文件,但会添加一个“哈希”而不是月份名称:~/test_output_2017-ea3c0c2dd56c499a93412641e41008db-01.log内容相同:2017-ea3c0c2dd56c499a93412641e41008db-01如果我在s

Linux shell 脚本 : make a folder with the current date name

我正在尝试制作一个简单的备份脚本,但在创建名称为当前日期的文件夹时遇到问题我的脚本就是这样,基本上问题在最后一行drivers=$(ls/media/)declare-ic=0forwordin$driversdoecho"($c)$word"c=c+1doneread-n1driveechoc=0forwordin$driversdoif[$c-eq$drive]thenbackuppath="/media/$word/backup"fic=c+1doneecho"doingbackupto$backuppath"cp-r/home/stefanos/Programming$back

linux - 在 bash 中使用'rm'- 到 'delete by date' 有什么简单的方法吗?

我今天注意到(在愉快地使用bash进行了大约8年的黑客攻击之后),没有简单的方法可以使用“rm”来“按日期删除”。因此,解决方案是围绕诸如rm、ls、find、awk和sed等命令的组合来传输内容。例如,我想删除工作目录中自2009年以来的所有文件,典型的方法是什么?我想到了以下内容,它非常丑陋,只有在“rm”设置为跳过目录时才应该运行(否则您将删除父目录):ls-la|awk'{if(substr($6,0,5)==2009)print$8}'|xargsrm最优雅和最离谱的过度设计解决方案的分数。 最佳答案 我会结合find和r

linux - 使用 linux 命令 "date"添加一些特定时间

在linux中,date可以帮助我打印当前时间。如果要打印当前时间+1小时,我应该给什么选项? 最佳答案 在Linux上只需使用-d(或--date)对日期进行一些数学计算:date-d'+1hour''+%F%T'#^^^^^^^^^^^^例如:$date'+%F%T'2013-04-2210:57:24$date-d'+1hour''+%F%T'2013-04-2211:57:24#^Mac操作系统警告,以上仅适用于Linux,不适用于MacOS。在MacOS上,等效的命令是date-v+1H

linux - git:gitk 有 "Sort by date"的命令行选项吗?

我正在尝试为gitk找到一个命令行选项,它与“查看/编辑View...”窗口中的“严格按日期排序”具有相同的效果。与GUI中可用的选项相比,mangitk显示的选项数量非常有限。 最佳答案 mangitk至少提到它确实采用了与gitrev-list相同的选项,包括--date-orderThisoptionissimilarto--topo-orderinthesensethatnoparentcomesbeforeallofitschildren,butotherwisethingsarestillorderedinthecomm

php.ini 默认时区与 date.timezone

当我在两个不同的服务器上使用PHP的date()函数时,我得到两个不同的结果,但是两个服务器应该是相同的。我检查了服务器#1上的php.ini文件,时间是正确的,它看起来如下:date/timesupportenabled"Olson"TimezoneDatabaseVersion0.systemTimezoneDatabaseinternalDefaulttimezoneAmerica/ChicagoDirectiveLocalValueMasterValue---------------------------------------------------date.timezon

php - 使用 date() 函数显示特定时区的时间/日期

我使用date()函数获取日、月和年。$year=date(y);$month=date(m);$day=date(d);但是我的托管在我所在的另一个地方,所以我需要增加11个小时。你能告诉我我该怎么做吗?谢谢 最佳答案 要么做date('Y-m-d',strtotime('+11hours'));添加11小时或创建一个DateTime对象并在需要时更改它的时区$datetime=newDateTime;//currenttime=servertime$otherTZ=newDateTimeZone('America/Los_Ang

PHP date - 以本地语言获取月份的名称

我有这部分功能,它给了我英文月份的名称。如何将它们翻译成我的本地语言(塞尔维亚语)?$month_name=date('F',mktime(0,0,0,$i));其中$i是月份的编号(值1-12)。另见PHP:mktime. 最佳答案 你应该使用setlocale():setlocale(LC_TIME,'fr_FR');$month_name=date('F',mktime(0,0,0,$i));在这种情况下,它会将其设置为法语。对于您的情况,它应该是以下之一:sr_BA-塞尔维亚语(黑山)sr_CS-塞尔维亚语(塞尔维亚)sr_

php - 警告 : date_format() expects parameter 1 to be DateTime

我正在使用以下脚本从mysql数据库中提取日历信息并将其显示在页面上。我正在尝试从标准Mysql日期格式重新格式化日期,但是从数据库中检索它时出现以下错误:Warning:date_format()expectsparameter1tobeDateTime,stringgiveninC:\easyphp\www\twinfocus\managecalendar.phponline24Warning:date_format()expectsparameter1tobeDateTime,stringgiveninC:\easyphp\www\twinfocus\managecalendar