便利的获取系统的时分秒
系统 获取 便利 时分秒
2023-09-14 08:57:16 时间
便利的获取系统的时分秒
源码如下:
GlobalNormalTime.h 与 GlobalNormalTime.m
// // GlobalNormalTime.h // YouXianMingClock // Created by YouXianMing on 14-10-12. // Copyright (c) 2014年 YouXianMing. All rights reserved. #import Foundation/Foundation.h @interface GlobalNormalTime : NSObject * 当前时间的数组 * @return 返回有3个元素的数组(0处为小时,1处为分钟,2处为秒) + (NSArray *)currentTime; * 当前秒 * @return 当前秒 + (float)currentSecond; * 当前分钟 * @return 当前分钟 + (float)currentMinute; * 当前小时 * @return 当前小时 + (float)currentHour; @end
// // GlobalNormalTime.m // YouXianMingClock // Created by YouXianMing on 14-10-12. // Copyright (c) 2014年 YouXianMing. All rights reserved. #import "GlobalNormalTime.h" static NSDateFormatter* _DMLogDateFormatter = nil; @implementation GlobalNormalTime + (void)initialize if (self == [GlobalNormalTime class]) { // 日期格式 _DMLogDateFormatter = [[NSDateFormatter alloc] init]; [_DMLogDateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; [_DMLogDateFormatter setDateFormat:@"HH:mm:ss"]; + (NSArray *)currentTime NSString *timerNow = [_DMLogDateFormatter stringFromDate:[NSDate date]]; NSArray *timeArray = [timerNow componentsSeparatedByString:@":"]; return timeArray; + (float)currentSecond NSString *timerNow = [_DMLogDateFormatter stringFromDate:[NSDate date]]; NSArray *timeArray = [timerNow componentsSeparatedByString:@":"]; // 获取到时间 float sec = [timeArray[2] intValue]; return sec; + (float)currentMinute NSString *timerNow = [_DMLogDateFormatter stringFromDate:[NSDate date]]; NSArray *timeArray = [timerNow componentsSeparatedByString:@":"]; // 获取到时间 float min = [timeArray[1] intValue]; return min; + (float)currentHour NSString *timerNow = [_DMLogDateFormatter stringFromDate:[NSDate date]]; NSArray *timeArray = [timerNow componentsSeparatedByString:@":"]; // 获取到时间 float hour = [timeArray[0] intValue]; return hour; @end
以下提供简易分析,使用非常简单,试一下就知道了
C++ 日期和时间编程总结 在 C++11 之前,C++ 编程只能使用 C-style 日期时间库,其精度只有秒级别,这对于有高精度要求的程序来说,是不够的。但这个问题在C++11 中得到了解决,C++11 中不仅扩展了对于精度的要求,也为不同系统的时间要求提供了支持。另一方面,对于只能使用 C-style 日期时间库的程序来说,C++17 中也增加了 timespec 将精度提升到了纳秒级别。
我花了一个星期,做出了公司的管理系统,只需几个步骤! 我是企业的管理人员,公司发展到现阶段,感觉进入到了瓶颈期,每个员工的工作都已经饱和,很难再挤出时间做其它的事情,需要一款合适的管理软件来协作我们的工作。本来打算买一套管理软件就行了,现实却并没有那么简单。
相关文章
- C# 系统应用之通过注册表获取USB使用记录(一)
- python之psutil模块(获取系统性能数据)
- C#遍历系统所安装的打印机,使用WMI方式获取打印机的所有属性
- Swoole跟thinkphp5结合开发WebSocket在线聊天通讯系统
- EasyIPCamera实现Windows PC桌面、安卓Android桌面同屏直播,助力无纸化会议系统
- 获取系统当前目录
- 系统思维
- Shell 实现系统初始化 修改IP
- SAP系统和微信集成的系列教程之六:如何通过OAuth2获取微信用户信息并显示在SAP UI5应用中
- 说说大型高并发高负载网站的系统架构
- Android图形显示系统——上层显示1:界面绘制大纲
- IO流文件的相对路径及获取系统路径方法
- Android 获取当前系统输入法和修改系统输入法
- 企业建站系统MiinCMP1.0.5 标准版公布!
- Python编程:psutil模块获取系统信息
- 【ChatGPT】揭秘:ChatGPT 系统架构技术栈
- MES系统能为制造企业解决哪些问题
- OpenLDAP 自助修改密码系统——筑梦之路
- Python 3 自动化运维之psutil获取系统进程
- win10开机Log界面一直转圈,进不去系统自动修复失败
- Linux系统中安装mysql注意事项
- Linux 为什么系统的Swap变高了?(下)
- APM监控系统 微服务接入SkyWalking
- Android系统信息获取 之十三:Linux内核版本信息获取
- Android系统信息获取 之二:版本信息获取