iOS判断当前时间是否处于某个时间段内
/**
* 判断当前时间是否处于某个时间段内
*
* @param startTime 开始时间
* @param expireTime 结束时间
*/ - (BOOL)validateWithStartTime:(NSString *)startTime withExpireTime:(NSString *)expireTime {
NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
// 时间格式,此处遇到过坑,建议时间HH大写,手机24小时进制和12小时禁止都可以完美格式化
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm"]; NSDate *start = [dateFormat dateFromString:startTime];
NSDate *expire = [dateFormat dateFromString:expireTime]; if ([today compare:start] == NSOrderedDescending && [today compare:expire] == NSOrderedAscending) {
return YES;
}
return NO;
}
如果你不是在wb145230博客园看到本文,请点击查看原文.
iOS判断当前时间是否处于某个时间段内的更多相关文章
- c# 判断当前时间是否在 工作日时间段内
#region //获取当前周几 private string _strWorkingDayAM = "08:30";//工作时间上午08:00 private string _s ...
- .net判断当前时间是否在工作时间段内
整理代码,判断当前时间是否在配置的工作时间段内,代码如下: public static bool getTimeSpan(string _strWorkingDayAM, string _strWor ...
- Windows服务定时运行,判断当前时间是否在配置时间段内
/// <summary> /// 判断程序是否在设置运行时间内 /// </summary> /// <param name="startTime" ...
- 【.Net 学习系列】-- Windows服务定时运行,判断当前时间是否在配置时间段内
/// <summary> /// 判断程序是否在设置运行时间内 /// </summary> /// <param name="startTime" ...
- js 判断当前时间是否处于某个一个时间段内
js 判断当前时间(或者所选时间)是否在某一时间段 我们可以使用 jutils - JavaScript常用函数库的 isDuringDate 函数来实现 传入 beginDateStr (开始时间) ...
- sqlServer通过指定的起始时间,创建该时间段内以年、月、日为时间段的临时表
通过指定的起始时间,创建该时间段内以年.月.日为时间段的临时表 ALTER PROCEDURE [dbo].[YOUR_SP_Name] -- Add the parameters for t ...
- ios中利用NSDateComponents、NSDate、NSCalendar判断当前时间是否在一天的某个时间段内。
应用中设置一般会存在这样的设置,如夜间勿扰模式,从8:00-23:00,此时如何判断当前时间是否在该时间段内.难点主要在于如何用NSDate生成一个8:00的时间和23:00的时间,然后用当前的时间跟 ...
- c# 判断时间是否在 某一时间段内
protected bool getTimeSpan(string timeStr) { //判断当前时间是否在工作时间段内 string _strWorkingDayAM = "08:30 ...
- iOS 断当前时间是否在一天的某个时间段内。
应用中设置一般会存在这样的设置,如夜间勿扰模式,从8:00-23:00,此时如何判断当前时间是否在该时间段内.难点主要在于如何用NSDate生成一个8:00的时间和23:00的时间,然后用当前的时间跟 ...
随机推荐
- zxing的使用及优化
二维码介绍 zxing项目是谷歌推出的用来识别多种格式条形码的开源项目,项目地址为https://github.com/zxing/zxing,zxing有多个人在维护,覆盖主流编程语言,也是目前还在 ...
- 【27.22%】【poj2991】Crane
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5772 Accepted: 1571 Special Judge D ...
- tky项目第②个半月总结
在上一篇半月总结中,介绍了tky项目的整体架构.项目的进展情况.项目的优势与开发中存在的问题等.今天来聊聊这半个月中,项目中发生的事情. 在这半个月中,项目中有了较大的突破:成功通过了国家评測中心的測 ...
- [Angular] Difference between ngAfterViewInit and ngAfterContentInit
Content is what is passed as children. View is the template of the current component. The view is in ...
- 【BZOJ 1033】 [ZJOI2008]杀蚂蚁antbuster(判断线段是否和圆相交)
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1033 [题意] https://www.zybuluo.com/Jerusalem/n ...
- WPF 好看的矢量图标
原文:WPF 好看的矢量图标 本文告诉大家一个好用的网站,里面提供很多好看的图标. 本文介绍的网站是 Xamalot 里面有很多好看的图标. 例如我找到了一个好看的图标 我只需要点击下面的下载就可以了 ...
- IP packet transmission using vehicular transport
In one embodiment, a first stationary router may detect a disconnected backhaul link to a destinatio ...
- Failed during checkstyle execution: Unable to find suppressions file at location: src/checkstyle/checkstyle-suppressions.xml
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...
- Android官方教程翻译(4)——启动另一个Activity
Starting Another Activity 启动另一个Activity PREVIOUSNEXT THIS LESSON TEACHES YOU TO 这节课教你 1. Respond t ...
- [MVVM Light]Messenger 的使用
原文:[MVVM Light]Messenger 的使用 当我们使用MVVM开发模式进行开发时,ViewModel之间的通信常常是很头疼的事情,好在MVVM Light提供了Messenger类可以轻 ...