- 浏览: 595937 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
月光杯:
问题解决了吗?
Exceptions in HDFS -
iostreamin:
神,好厉害,这是我找到的唯一可以ac的Java代码,厉害。
[leetcode] word ladder II -
standalone:
One answer I agree with:引用Whene ...
How many string objects are created? -
DiaoCow:
不错!,一开始对这些确实容易犯迷糊
erlang中的冒号 分号 和 句号 -
standalone:
Exception in thread "main& ...
one java interview question
几种我所用到的用来处理日期,时间的函数总结。
Perl
1. localtime
If parameter is not provides, it will use current time. Note the $year returned contains the number of years since 1900, to get a 4-digit year you need:
$year += 1900;
And the $mon starts from 0 to 11.
2. strftime
Strftime 时间域 ( 这个和 date 的命令的字符格式是一样的), 参见
http://www.php-oa.com/2010/08/21/perl-strftime.html
% H 小时(00..23)
% I 小时(01..12)
% k 小时(0..23)
% l 小时(1..12)
% M 分(00..59)
% p 显示出AM或PM
% r 时间(hh:mm:ss AM或PM),12小时
% s 从1970年1月1日00:00:00到目前经历的秒数
% S 秒(00..59)
% T 时间(24小时制)(hh:mm:ss)
% X 显示时间的格式(%H:%M:%S)
% Z 时区 日期域
% a 星期几的简称( Sun..Sat)
% A 星期几的全称( Sunday..Saturday)
% b 月的简称(Jan..Dec)
% B 月的全称(January..December)
% c 日期和时间( Mon Nov 8 14:12:46 CST 1999)
% d 一个月的第几天(01..31)
% D 日期(mm/dd/yy)
% h 和%b选项相同
% j 一年的第几天(001..366)
% m 月(01..12)
% w 一个星期的第几天(0代表星期天)
% W 一年的第几个星期(00..53,星期一为第一天)
% x 显示日期的格式(mm/dd/yy)
% y 年的最后两个数字( 1999则是99)
% Y 年(例如:1970,1996等)
3. time
Returns the number of non-leap seconds since whatever time the system considers to be the epoch, suitable for feeding to gmtime and localtime. On most systems the epoch is 00:00:00 UTC, January 1, 1970
4. Date::Calc
Quite useful. Some methods I frequently use:
Add_Delta_Days
($year,$month,$day) =
Add_Delta_Days($year,$month,$day,
$Dd);
Today
($year,$month,$day) = Today([$gmt]);
Now
($hour,$min,$sec) = Now([$gmt]);
Delta_Days
$Dd = Delta_Days($year1,$month1,$day1,
$year2,$month2,$day2);
5. Date::Parse
http://search.cpan.org/~gbarr/TimeDate-2.30/lib/Date/Parse.pm
Used to parse date string into time values.
str2time(DATE [, ZONE])
str2time parses DATE and returns a unix time value, or undef upon failure. ZONE, if given, specifies the timezone to assume when parsing if the date string does not specify a timezone.
strptime(DATE [, ZONE])
strptime takes the same arguments as str2time but returns an array of values ($ss,$mm,$hh,$day,$month,$year,$zone). Elements are only defined if they could be extracted from the date string. The $zone element is the timezone offset in seconds from GMT. An empty array is returned upon failure.
Java
参考:http://tianlovv.iteye.com/blog/402116
JavaScript
创建一个日期对象:
var objDate=new Date([arguments list]);
参数形式有以下5种:
new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms);
需要注意最后一种形式,参数表示的是需要创建的时间和GMT时间1970年1月1日之间相差的毫秒数。各种函数的含义如下:
month:用英文表示月份名称,从January到December
mth:用整数表示月份,从0到11
dd:表示一个月中的第几天,从1到31
yyyy:四位数表示的年份
hh:小时数,从0(午夜)到23(晚11点)
mm:分钟数,从0到59的整数
ss:秒数,从0到59的整数
ms:毫秒数,为大于等于0的整数
参考:
http://www.cnblogs.com/east-liujie/archive/2006/10/21/535784.html
Sybase
http://wang-zhi-peng2007.iteye.com/blog/1199091
Perl
1. localtime
# 0 1 2 3 4 5 6 7 8 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
If parameter is not provides, it will use current time. Note the $year returned contains the number of years since 1900, to get a 4-digit year you need:
$year += 1900;
And the $mon starts from 0 to 11.
2. strftime
use POSIX qw(strftime); $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; # or for GMT formatted appropriately for your locale: $now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime;
Strftime 时间域 ( 这个和 date 的命令的字符格式是一样的), 参见
http://www.php-oa.com/2010/08/21/perl-strftime.html
% H 小时(00..23)
% I 小时(01..12)
% k 小时(0..23)
% l 小时(1..12)
% M 分(00..59)
% p 显示出AM或PM
% r 时间(hh:mm:ss AM或PM),12小时
% s 从1970年1月1日00:00:00到目前经历的秒数
% S 秒(00..59)
% T 时间(24小时制)(hh:mm:ss)
% X 显示时间的格式(%H:%M:%S)
% Z 时区 日期域
% a 星期几的简称( Sun..Sat)
% A 星期几的全称( Sunday..Saturday)
% b 月的简称(Jan..Dec)
% B 月的全称(January..December)
% c 日期和时间( Mon Nov 8 14:12:46 CST 1999)
% d 一个月的第几天(01..31)
% D 日期(mm/dd/yy)
% h 和%b选项相同
% j 一年的第几天(001..366)
% m 月(01..12)
% w 一个星期的第几天(0代表星期天)
% W 一年的第几个星期(00..53,星期一为第一天)
% x 显示日期的格式(mm/dd/yy)
% y 年的最后两个数字( 1999则是99)
% Y 年(例如:1970,1996等)
3. time
Returns the number of non-leap seconds since whatever time the system considers to be the epoch, suitable for feeding to gmtime and localtime. On most systems the epoch is 00:00:00 UTC, January 1, 1970
4. Date::Calc
Quite useful. Some methods I frequently use:
Add_Delta_Days
($year,$month,$day) =
Add_Delta_Days($year,$month,$day,
$Dd);
Today
($year,$month,$day) = Today([$gmt]);
Now
($hour,$min,$sec) = Now([$gmt]);
Delta_Days
$Dd = Delta_Days($year1,$month1,$day1,
$year2,$month2,$day2);
5. Date::Parse
http://search.cpan.org/~gbarr/TimeDate-2.30/lib/Date/Parse.pm
Used to parse date string into time values.
str2time(DATE [, ZONE])
str2time parses DATE and returns a unix time value, or undef upon failure. ZONE, if given, specifies the timezone to assume when parsing if the date string does not specify a timezone.
strptime(DATE [, ZONE])
strptime takes the same arguments as str2time but returns an array of values ($ss,$mm,$hh,$day,$month,$year,$zone). Elements are only defined if they could be extracted from the date string. The $zone element is the timezone offset in seconds from GMT. An empty array is returned upon failure.
Java
参考:http://tianlovv.iteye.com/blog/402116
JavaScript
创建一个日期对象:
var objDate=new Date([arguments list]);
参数形式有以下5种:
new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms);
需要注意最后一种形式,参数表示的是需要创建的时间和GMT时间1970年1月1日之间相差的毫秒数。各种函数的含义如下:
month:用英文表示月份名称,从January到December
mth:用整数表示月份,从0到11
dd:表示一个月中的第几天,从1到31
yyyy:四位数表示的年份
hh:小时数,从0(午夜)到23(晚11点)
mm:分钟数,从0到59的整数
ss:秒数,从0到59的整数
ms:毫秒数,为大于等于0的整数
参考:
http://www.cnblogs.com/east-liujie/archive/2006/10/21/535784.html
Sybase
http://wang-zhi-peng2007.iteye.com/blog/1199091
发表评论
-
lost on Py_DECREF/INCREF when handling PyList_Append in Python C extension
2015-11-03 21:41 1011The main hint is in the docs, i ... -
How can I convert a character to a integer in Python, and viceversa?
2015-10-27 14:38 699Use chr() and ord(): >>& ... -
ssl 与 java 实例
2014-01-27 10:10 750http://www.iteye.com/topic/1125 ... -
Java NIO
2014-01-10 21:28 703看了这个java nio的教程,明白了什么是Selector. ... -
perl tips for qw qq qx q
2013-07-26 16:58 1785q// is generally the same thing ... -
再谈Java的wait(), sleep(), notify()和notifyAll()
2013-07-25 10:59 1872一段时间不用java,这些概念就全混淆了,有必要彻底澄清一下, ... -
shell字符串截取
2013-07-19 15:09 848${string#substring} 从string左边去掉 ... -
Why singleton is anti-pattern?
2013-07-03 10:12 873OO Test Other reasons? -
How to generate the serialVersionUID when you implement Serializable interface,j
2013-07-01 10:52 919http://docs.oracle.com/javase/6 ... -
Serialize/Deserialize Perl Class Objects
2013-06-18 14:09 1827Today in a small project I need ... -
一个命令创建多个目录
2013-06-13 12:36 887可能我太土了,才发现下面这个命令! mkdir -p src ... -
Java Override的两个问题
2013-06-01 11:40 9261: 如果子类中的方法的参数是父类的方法的子类型,那么算不算o ... -
Java常用类API统计
2013-06-01 11:35 0String charAt(int) compareTo( ... -
How many string objects are created?
2013-06-01 10:18 1315This is a very common java inte ... -
使用Java的DelayQueue容易碰到的一个坑
2013-05-27 17:32 6671今天不忙,学习一下java.util.concurrent.D ... -
[leetcode] Balanced Binary Tree
2013-04-28 14:08 1563Check if a binary tree is balan ... -
[leetcode] find median of two sorted arrays
2013-04-26 10:55 1437http://leetcode.com/onlinejudge ... -
[leetcode] word ladder
2013-04-25 15:05 2257Q: Given two words (start and ... -
[leetcode] word ladder II
2013-04-15 07:35 11646http://leetcode.com/onlinejudge ... -
Use CGI::Application under mod_perl [TO DO]
2013-04-12 14:14 7Here is an summary on how to us ...
相关推荐
javascript函数的解释,解释了具体函数的功能,一、函数JavaScript函数集合 1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4.一个浏览器窗口中的DOM顺序是:...
2.17 do/while重复结构 2.18 break和continue语句 2.19 逻辑运算符 2.20 混淆相等(.==)与赋值(=)运算符 2.21 结构化编程小结 2.22 有关对象的思考:确定问题中的对象 小结 术语 自测练习 自测练习答案 ...
Time 函数 返回反映当前系统时间的日期子类型的变体。 Timer 函数 返回时经子夜 12:00 AM 后的秒数。 TimeSerial 函数 返回含有指定时分秒时间的日期子类型的变体。 TimeValue 函数 返回含有时间的日期子类型的...
所有变量都是局部变量,为了使得定义的函数中可以使用外部变量,使用global语句。而你要将该变量的作用范围限制在该函数之内,使用static语句。 $g_var = 1 ; // 全局范围 function test() { global $g_var; // 这样...
VBScript内部函数可分为:转换函数、字符串函数、日期和时间函数、数学函数和检验函数。 1.转换函数 VBScript对Variant变量一般会根据需要自动转换成合适的数据类型;但有时,自动转换有可能造成数据类型不匹配错误...
Time 函数 返回反映当前系统时间的日期子类型的变体。 Timer 函数 返回时经子夜 12:00 AM 后的秒数。 TimeSerial 函数 返回含有指定时分秒时间的日期子类型的变体。 TimeValue 函数 返回含有时间的日期子类型的...
Time 函数 返回反映当前系统时间的日期子类型的变体。 Timer 函数 返回时经子夜 12:00 AM 后的秒数。 TimeSerial 函数 返回含有指定时分秒时间的日期子类型的变体。 TimeValue 函数 返回含有时间的日期子类型的...
<END><br>21,frmmain.zip This will calculate your midterm and final grade average.<END><br>22,taxes.zip This program computes weekly payroll, current earnings, year to date earnings FICA tax, ...
6.2.2 Date 和 Time 类型 6.2.2.1 Y2K 问题和日期类型 6.2.2.2 DATETIME、DATE 和 TIMESTAMP 类型 6.2.2.3 TIME 类型 6.2.2.4 YEAR 类型 6.2.3 字符串类型 6.2.3.1 CHAR 和 VARCHAR 类型 6.2.3.2 BLOB...
在文件的最后加入Nand Flash的初始化函数,该函数在后面Nand Flash的操作都要用到。 u-boot运行到第2阶段会进入start_armboot()函数。其中nand_init()函数是对nand flash的最 初初始化函数。nand_init()函数在两个...
Time 函数 返回反映当前系统时间的日期子类型的变体。 Timer 函数 返回时经子夜 12:00 AM 后的秒数。 TimeSerial 函数 返回含有指定时分秒时间的日期子类型的变体。 TimeValue 函数 返回含有时间的日期子类型的...
Time 函数 返回反映当前系统时间的日期子类型的变体。 Timer 函数 返回时经子夜 12:00 AM 后的秒数。 TimeSerial 函数 返回含有指定时分秒时间的日期子类型的变体。 TimeValue 函数 返回含有时间的日期子类型的...
2. 设置好配置文件,发现会报一个date函数的关于时区的警告,把php中的date.timezone加上date.timezone = Asia/Shanghai; 3. 老是报Call to undefined function openssl_get_publickey,把php.ini中的extension=...
@DeleteDocument 在代理中运行时此函数时,删除正在被处理的文档 @DeleteField 在代理中运行该函数,@DeleteField 将删除指定的域 @DialogBox 弹出一个对话框,用指定的表单显示当前的文档 @Do 从左到右计算表达式,...
Connected to an idle instance. SQL> startup^C SQL> startup ORACLE instance started. 2、在双机环境下 要想启动或关闭ORACLE系统必须首先切换到root用户,如下 su - root a、启动ORACLE系统 hareg -y ...
2.17 do/while重复结构 2.18 break和continue语句 2.19 逻辑运算符 2.20 混淆相等(.==)与赋值(=)运算符 2.21 结构化编程小结 2.22 有关对象的思考:确定问题中的对象 小结 术语 自测练习 自测练习答案 ...
11.3.1. DATETIME、DATE和TIMESTAMP类型 11.3.2. TIME类型 11.3.3. YEAR类型 11.3.4. Y2K事宜和日期类型 11.4. String类型 11.4.1. CHAR和VARCHAR类型 11.4.2. BINARY和VARBINARY类型 11.4.3. BLOB和TEXT类型 11.4.4...
tinytime导出单个函数,该函数返回模板对象。 该对象具有单个方法render ,该方法采用Date并返回包含渲染数据的字符串。 import tinytime from 'tinytime' ; const template = tinytime ( 'The time is {h}:{mm}:{...
9.4.3. Basic Zend_Date Operations Common to Many Date Parts 9.4.3.1. List of Date Parts 9.4.3.2. List of Date Operations 9.4.4. Comparing Dates 9.4.5. Getting Dates and Date Parts 9.4.6. Working ...
13.4.4. SAVEPOINT和ROLLBACK TO SAVEPOINT语法 13.4.5. LOCK TABLES和UNLOCK TABLES语法 13.4.6. SET TRANSACTION语法 13.4.7. XA事务 13.5. 数据库管理语句 13.5.1. 账户管理语句 13.5.2. 表维护语句 13.5.3. SET...