获取1970年1月1日以来的天数

#!/usr/bin/ksh
# AUTHOR:		Xin23
# Version:  Beta 0.1 
# Date:     2014-09-05

Get_Days_From_1970(){

BEGINYEAR=1970
ENDYEAR=$(date +%Y)
YEARNUM=$(($ENDYEAR-$BEGINYEAR))
LYEARNUM=$(($YEARNUM/4))
RNUM=${LYEARNUM%.*}
DAYNUMY=$(($YEARNUM*365))
DAYNUMZ=$(($DAYNUMY+$RNUM))
DAYNUMA=$(($(date +%j)+$DAYNUMZ))
echo $DAYNUMA

}

Get_Days_From_1970

#    此函数用来获取1970.1.1至今的天数

执行如下:

[aybq76:root]#./1970.sh

16319

[aybq76:root]#date

Fri Sep  5 13:52:57 BEIST 2014

[aybq76:root]#

时间: 2024-08-29 05:06:24

获取1970年1月1日以来的天数的相关文章

Java 获取各时区时间,获取当前时间到格林威治时间1970年01月01日00时00分00秒的秒数

格林威治时间即UTC/GMT时间,1970年01月01日00时00分00秒(即UTC+8的北京时间1970年01月01日08时00分00秒)计算代码如下: 1 /** 2 * 获取指定时间到格林威治时间的秒数 3 * UTC:格林威治时间1970年01月01日00时00分00秒(UTC+8北京时间1970年01月01日08时00分00秒) 4 * @param time 5 * @return 6 */ 7 public static long diffSeconds(String time){

日期类的时间从为什么是从1970年1月1日(格林威治时间)

I suspect that Java was born and raised on a UNIX system.UNIX considers the epoch (when did time begin) to be midnight, January 1, 1970.是说java起源于UNIX系统,而UNIX认为1970年1月1日0点是时间纪元. 但这依然没很好的解释"为什么",出于好奇,继续Google,总算找到了答案: http://en.wikipedia.org/wiki/

为什么编程时间从1970年1月1日開始?

查看原文:http://www.ibloger.net/article/136.html 最初计算机操作系统是32位,而时间也是用32位表示. System.out.println(Integer.MAX_VALUE); 2147483647 Integer在JAVA内用32位表示,因此32位能表示的最大值是2147483647. 另外1年365天的总秒数是31536000, 2147483647/31536000 = 68.1 也就是说32位能表示的最长时间是68年.而实际上到2038年01月

java为啥计算时间从1970年1月1日开始

http://www.myexception.cn/program/1494616.html ---------------------------------------------------------- java为什么计算时间从1970年1月1日开始 今天在看Python  API 时,看到 time 模块 : The epoch is the point where the time starts. On January 1st of that year, at 0 hours,the

为什么编程语言以及数据库要从1970年1月1日开始计算时

今天在看Python  API时,看到time模块: The epoch is the point where the time starts. On January 1st of that year, at 0 hours,the “time since the epoch” is zero. For Unix, the epoch is 1970. To find out what the epoch is, look at gmtime(0). 定义time从1970年1月1日开始,忽然想

判断距离1970年1月1日的天数

#include <stdlib.h> /****************************************************************** 功能: 输入年月日,计算距离1970年1月1日的天数 输入: 年月日,输入年份范围[1970,2100],输入年月日的有效性需要判断 输出: DaysSince1970:距离1970年1月1日的天数 已知 1970年1月1日为星期四 异常时,输出不需要关注 返回: 1 上班 0 休假 -1 表示异常 根据国家规定:周一到

为什么编程时间从1970年1月1日开始?

最初计算机操作系统是32位,而时间也是用32位表示. System.out.println(Integer.MAX_VALUE); 2147483647 Integer在JAVA内用32位表示,因此32位能表示的最大值是2147483647.另外1年365天的总秒数是31536000, 2147483647/31536000 = 68.1 也就是说32位能表示的最长时间是68年,而实际上到2038年01月19日03时14分07秒,便会到达最大时间,过了这个时间点,所有32位操作系统时间便会变为

iOS Dev (55) 获取当前年、月、日等信息

iOS Dev (55) 获取当前年.月.日等信息 作者:大锐哥 博客:http://prevention.iteye.com - NSDate *now = [NSDate date]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUn

【转】java获取当前年、月、日 、小时 、分钟、 秒、 毫秒

public class Test { /** * 英文简写(默认)如:2010-12-01 */ public static String FORMAT_SHORT = "yyyy-MM-dd"; /** * 英文全称 如:2010-12-01 23:15:06 */ public static String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss"; /** * 精确到毫秒的完整时间 如:yyyy-MM-dd HH:mm:ss.S