Ruby Time类和Date类
Time类
| 年月日时分秒,时区 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 生成 |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 获取属性的值 | t = Time.new()
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 比较 | t1 = Time.new() t2 = Time.mktime(2018, 1, 1) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 输出 | t.to_s() t.strftime(format)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 转换 |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| time库 | require "time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 邮件日期格式 | t.rfc2822() Request For Comments 的RFC2822而来 Mon, 22 May 2017 02:39:13 +0900 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 国际标准表示 | t.iso8601() 2017-05-22T02:39:13+09:00 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 文字转日期 |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 年月日 | |||||||||||
| require "date" | |||||||||||
| 生成 |
|
||||||||||
| 运算 |
|
||||||||||
| 输出 | t.to_s() t.strftime("%Y/%m/%d") |
||||||||||
| 转换 |
|
||||||||||
| Data/Time相关的有用的方法 | |
| yesterday | 昨天 |
| tomorrow | 明天 |
| prev_xxxx | 前年/月/周(year,month,week) |
| next_xxxx | 下年/月/周(year,month,week) |
| beginning_of_xxxx | 年/季/月/周的开始一天(year, quarter, month, day) |
| end_of_xxxx | 年/季/月/周的最后一条(year, quarter, month, day) |
| n.xxx.ago Numeric |
n个年/月/日/时/分/秒以前 years, months, days, hours, minutes, seconds 也可以用单数 |
| n.xxx.from_now Numeric |
n个年/月/日/时/分/秒以后 years, months, days, hours, minutes, seconds 也可以用单数 |
Ruby Time类和Date类的更多相关文章
- Math类、Random类、System类、BigInteger类、BigDecimal类、Date类、SimpleDateFormat、Calendar类
Math类* A:Math类概述 * Math 类包含用于执行基本数学运算的方法,如初等指数.对数.平方根和三角函数. * B:成员方法 * public static int abs(int a) ...
- ruby Time类与Date类
Time类用于表示时间.时间除了表示年月日时分秒的信息外,还包含了表示地域时差的时区(time zone)信息.例如我们可以计算中国当前时间是国际协调时间的几点 Date类只用于表示年月日.因此,相对 ...
- 14-03 java BigInteger类,BigDecimal类,Date类,DateFormat类,Calendar类
BigInteger类 发 package cn.itcast_01; import java.math.BigInteger; /* * BigInteger:可以让超过Integer范围内的数据进 ...
- 正则表达式、Calendar类、SimpleDateFormat类、Date类、BigDecimal类、BigInteger类、System类、Random类、Math类(Java基础知识十四)
1.正则表达式的概述和简单使用 * A:正则表达式(一个字符串,是规则) * 是指一个用来描述或者匹配一系列符合某个语法规则的字符串的单个字符串.其实就是一种规则.有自己特殊的应用. * B: ...
- 处理时间的类 —— System类、Date类 、SimpleDateFormat类 与 Calendar类
在我们以往的编程中,就有过通过运行前和运行后时间差来判断时间复杂度的例子,再扯得远一点,我们在C语言中制造随机数的操作,也要用到有关时间的函数.而且,在我们未来的编程中,也会时不时要用到能够读取当前时 ...
- 时间日期相关类:Date类,DateFormat类&SimpleDateFormat类,Calendar类
日期相关类 1.Date类:日期时间类 A.构造方法 Date(): 根据当前系统时间创建日期对象 Date(Long time):根据传入的毫秒值时间创建日期对象 B.成员方法 Long get ...
- Object类、Date类、Calendar类、System类、StringBuilder类和基本类型包装类
一.Object类--toString方法 1.普通类重写toString方法,不然打印出来是存在栈内存的对象引用名称的堆内存中该对象的地址值: 2.equals方法: String比较equals是 ...
- C++实现日期类(Date类)
#include<iostream>using namespace std;class Date{public: Date(int year = 1900, int month = ...
- String类与Date类的转换
public class DateTest { public static void main(String[] args) throws ParseException { Date date = n ...
随机推荐
- webmagic使用手册
https://my.oschina.net/flashsword/blog/180623 重点 SeleniumDownloader 对于一些Javascript动态加载的网页,仅仅使用http模拟 ...
- linux 开机启动脚本或者服务
https://blog.csdn.net/zhuchunyan_aijia/article/details/53811368
- Multiply Strings(字符串乘法模拟,包含了加法模拟)
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...
- CodeForces 582A【multiset使用样例】
题意: 给一些无序的数字,求解一个矩阵,使得矩阵的每一个元素都是行和列标志数的gcd,输出行标志数. 首先对数字进行排序.复杂度n*log(n^2). 这题的证明有官方的英文题解==在这直接贴英文题解 ...
- SSM!这就是你要的条条框框!
第一次写博 1.导jar包 2,.表和实体类 实体类:com.bao.entity[Student] private int stuNo; private String stuName; privat ...
- linux命名详解及其软件安装实例
始于cd,ls命令 好啦,步入正题,我使用的linux连接工具为xshell,mRemoteNG,对两款工具不做介绍啦,你可以百度一下,实在不会入左上方群. 进入之后,便是上面的界面黑乎乎一片,对于初 ...
- linux上安装启动elasticsearch-5.5.1完整步骤
linux上安装启动elasticsearch-5.5.1完整步骤 学习了:https://blog.csdn.net/hingcheung/article/details/77144574 http ...
- Windows7系统下优化固态硬盘
一.AHCI硬盘模式可提高硬盘性能,确定你的固态硬盘是运行在AHCI模式下,打开“HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servicesmsahci” ...
- LUA协程复用
-----协程复用根函数 local function routine(fun, args) while (fun) do fun, args = coroutine.yield(fun(table. ...
- [RxJS] Implement RxJS `concatMap` by Waiting for Inner Subscriptions to Complete
Unlike mergeMap and switchMap, concatMap focuses on when "inner" subscriptions "compl ...