Swift3.0 iOS获取当前时间 - 年月日时分秒星期
Swift3.0 iOS获取当前时间 - 年月日时分秒星期
func getTimes() -> [Int] {
var timers: [Int] = [] // 返回的数组
let calendar: Calendar = Calendar(identifier: .gregorian)
var comps: DateComponents = DateComponents()
comps = calendar.dateComponents([.year,.month,.day, .weekday, .hour, .minute,.second], from: Date())
timers.append(comps.year! % ) // 年 ,后2位数
timers.append(comps.month!) // 月
timers.append(comps.day!) // 日
timers.append(comps.hour!) // 小时
timers.append(comps.minute!) // 分钟
timers.append(comps.second!) // 秒
timers.append(comp.weekday! - ) //星期
return timers;
}
Swift3.0 iOS获取当前时间 - 年月日时分秒星期的更多相关文章
- java 获得当前时间 年月日时分秒 星期几
<%SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");//设置日期格式SimpleDat ...
- C#:获取时间年月日时分秒格式
//获取日期+时间 DateTime.Now.ToString(); // 2008-9-4 20:02:10 DateTime.Now.ToLocalTime().ToStri ...
- iOS - 获取系统时间年月日,阳历(公历)日期转农历的方法
//获取当前时间 NSDate *now = [NSDate date]; NSLog(@" now date is: %@ ",now); NSCalendar *calenda ...
- sqlserver 获取时间年月日时分秒
转自:http://blog.itpub.net/14766526/viewspace-1156100/ select GETDATE() as '当前日期',DateName(year,GetDat ...
- js获取当前的年月日时分秒周期
function timeNow(){ var date = new Date(); this.year = date.getFullYear(); this.month = date.getMont ...
- js如何获得系统时间年月日时分秒
javascript 自带有个对象(构造函数),Date().下面是代码: 回答一: var now = new Date(); var nowTime = now.toLocaleString() ...
- 【第六篇】javascript显示当前的时间(年月日 时分秒 星期)
不多说自己上代码 这是我开始学javascript写的,现在发出来 <span id="clock" ></span> function time() { ...
- js获取年月日时分秒星期
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js 获取当前年月日时分秒星期
$("#aa").click(function () { var date = new Date(); this.year = date.getFullYear(); this.m ...
随机推荐
- 【读书笔记】iOS-NSString的length
NSString的length方法能够准确无误地处理国际字符串,如含有俄文,中文或者日本文字符的字符串,以及使用Unicode国际字符标准的字符串.在C语言中处理这些国际字符串是件令人非常头疼的事情 ...
- UIView简单动画
UIView动态实现的效果有以下几种: 1.动态改变frame 2.动态改变color 3.动态改变alpha 4.动态改变bounds 首先,我们先看几种BasicView动画 #pragma ma ...
- 弃用的异步get和post方法之代理方法
#import "ViewController.h" #import "Header.h" @interface ViewController () <N ...
- android 之 桌面的小控件AppWidget
AppWidget是创建的桌面窗口小控件,在这个小控件上允许我们进行一些操作(这个视自己的需要而定).作为菜鸟,我在这里将介绍一下AppWeight的简单使用. 1.在介绍AppWidget之前,我们 ...
- android 之 spinner的简单使用
先看spinner的效果图: 代码: MainActivity package com.mecury.spinnertest; import java.util.ArrayList; import a ...
- android network develop(3)----Xml Parser
Normally, there are three type parser in android. Xmlpullparser, DOM & SAX. Google recomand Xmlp ...
- Erlang 虚拟机 BEAM 指令集之内存管理相关的指令
翻看 BEAM 虚拟机指令集的时候(在编译器源码目录下:lib/compiler/src/genop.tab),会发现有一些和内存分配/解除分配相关的指令,如下所示: allocate StackNe ...
- 用C#实现RSS的生成和解析,支持RSS2.0和Atom格式
RSS已经非常流行了,几乎所有有点名气的和没名气的网站都有提供RSS服务. 本文详细教你什么是RSS,如是在.Net中使用RSS. 1.那么什么是RSS呢? RSS是一种消息来源格式规范,用以发布经常 ...
- Effective Java 71 Use lazy initialization judiciously
Lazy initialization - It decreases the cost of initializing a class or creating an instance, at the ...
- 【转】PaxosLease算法--2PC看Paxos选主
原文请参考[[置顶] Paxos master选举--PaxosLease算法] 众所周知,为了避免Paxos算法的活锁问题,必须选举唯一的proposor.偏偏在Paxos原论文中,作者L. Lam ...