iOS 关于时间天数星期月份的总结
#import <Foundation/Foundation.h>
@interface NSDate (SLExtend)
// 判断是否是本周更早
- (BOOL)isThisWeekEarlier;
// 判断是否是本周晚些
- (BOOL)isThisWeekLater;
// 判断是否是下一周或者更远
- (BOOL)isNextWeekOrLater;
// 判断是否是上一周或者更早
- (BOOL)isLastWeekOrEarlier;
// 判断是否是昨天或更早
- (BOOL)isYesterdayOrEarlier;
// 判断是否是明天或更晚
- (BOOL)isTomorrowOrLater;
// 判断是否是前天
- (BOOL)isTheDayBeforeYesterday;
// 判断是否是昨天
- (BOOL)isYesterDay;
// 判断是否是今天
- (BOOL)isToday;
// 判断是否是明天
- (BOOL)isTomorrow;
// 判断是否是后天
- (BOOL)isTheDayAfterTomorrow;
// 转换成年月日(其他补0)
- (NSDate *)convertDefinitionToDate;
// 转换标准时间
- (NSString *)convertToStandardDateFormat;
// 转换本星期标准时间
- (NSString *)convertToStandardThisWeekDateFormat;
// 转换成标准前天、昨天、今天、明天、后天时间
- (NSString *)convertToStandardRecentlyDateFormat;
// 转换成时间
- (NSString *)convertToStandardTimeDateFormat;
// 转换成标准时间(不带星期)
- (NSString *)convertToStandardNormalDateFormat;
// 转换成YYYY-MM-DD HH:MM:SS格式时间
- (NSString *)convertToStandardYYYYMMDDHHMMSSDateFormat;
// 转换成YYYY-MM-DD
- (NSString *)convertToStandardYYYYMMDDDateFormat;
// 转换成YYYYMMDDHHMMSS
- (NSString *)convertToYYYYMMDDHHMMSSDateFormat;
// 指定日期是星期几,1表示一周的第一天周日
+ (int)weekdayByDate:(NSDate *)date;
+ (NSString *)weekdayInChineseByDate:(NSDate *)date;
// 指定时间往前推多少天
+ (NSDate *)dateWithDays:(NSUInteger)days beforDate:(NSDate *)date;
+ (NSDate *)dateWithDays:(NSUInteger)days afterDate:(NSDate *)date;
// 获取某个时间点前多少天的总集合
+ (NSArray *)dayNamesAtDays:(NSInteger)days beforDate:(NSDate *)date;
// 获取年
+ (int)yearByDate:(NSDate *)date;
// 获取月
+ (int)monthByDate:(NSDate *)date;
// 获取日
+ (int)dayByDate:(NSDate *)date;
// 该日期处于一年中的第几周
+ (int)weekOfYearByDate:(NSDate *)date;
//获取当前的时间HH:mm
+ (NSString *)getCurrentDateHHMM;
//获取当前的时间yyyyMMdd HH:mm
+(NSString *)getCurrentDateYYYYMMDDHHMM;
//获取指定的时间yyyyMMdd
+(NSString *)getDateYYYYMMDD:(NSDate *)date;
// 该月有多少天
+ (int)daysInMonthByDate:(NSDate *)date;
+ (NSString *)convertToyyyMMddHHmmssString:(NSDate *)date;
+ (NSDate *)convertDateFromString:(NSString*)uiDate;
+ (NSDate *)stringToDate:(NSString *)dateString;
@end
#import "NSDate+SLExtend.h"
@implementation NSDate (SLExtend)
- (NSDate *)dateStartOfWeek
{
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setFirstWeekday:2]; //monday is first day
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit fromDate:self];
NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init];
[componentsToSubtract setDay: - ((([components weekday] - [gregorian firstWeekday]) + 7 ) % 7)];
NSDate *beginningOfWeek = [gregorian dateByAddingComponents:componentsToSubtract toDate:self options:0];
NSDateComponents *componentsStripped = [gregorian components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: beginningOfWeek];
beginningOfWeek = [gregorian dateFromComponents: componentsStripped];
return beginningOfWeek;
}
// ================================ 扩展 ===========================
// 判断是否是昨天或更早
- (BOOL)isYesterdayOrEarlier
{
NSDate *yesterdayDefintionDate = [NSDate dateWithTimeIntervalSinceNow:-60 * 60 * 24];
NSDate *definitionDate = [self convertDefinitionToDate];
if ([yesterdayDefintionDate isEqualToDate:definitionDate]) {
return YES;
}
NSDate *earlierDate = [definitionDate earlierDate:[NSDate date]];
if (earlierDate == self) {
return YES;
}
return NO;
}
// 判断是否是明天或更晚
- (BOOL)isTomorrowOrLater
{
NSDate *tomorrowDefintionDate = [NSDate dateWithTimeIntervalSinceNow:60 * 60 * 24];
NSDate *definitionDate = [self convertDefinitionToDate];
if ([tomorrowDefintionDate isEqualToDate:definitionDate]) {
return YES;
}
NSDate *laterDate = [definitionDate laterDate:tomorrowDefintionDate];
if (laterDate == self) {
return YES;
}
return NO;
}
// =================================================================
// 判断是否是下一周或者更远
- (BOOL)isNextWeekOrLater
{
if (![self isThisWeek]) {
NSDate *laterDate = [self laterDate:[NSDate date]];
if (laterDate == self) {
return YES;
}
}
return NO;
}
// 判断是否是上一周或者更早
- (BOOL)isLastWeekOrEarlier
{
if (![self isThisWeek]) {
NSDate *earlierDate = [self earlierDate:[NSDate date]];
if (earlierDate == self) {
return YES;
}
}
return NO;
}
// 判断是否是本周
- (BOOL)isThisWeek
{
NSDate *thisWeekStartDay = [[NSDate date] dateStartOfWeek];
if ([thisWeekStartDay isEqualToDate:[self dateStartOfWeek]]) {
return YES;
}
return NO;
}
// 判断是否是本周更早
- (BOOL)isThisWeekEarlier
{
if ([self isThisWeek]) {
NSDate *earlierDate = [self earlierDate:[NSDate date]];
if (earlierDate == self) {
return YES;
}
}
return NO;
}
// 判断是否是本周晚些
- (BOOL)isThisWeekLater
{
if ([self isThisWeek]) {
NSDate *laterDate = [self laterDate:[NSDate date]];
if (laterDate == self) {
return YES;
}
}
return NO;
}
// 判断是否是前天
- (BOOL)isTheDayBeforeYesterday
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit);
NSDateComponents *components = [cal components:calendarUnit fromDate:[NSDate dateWithTimeIntervalSinceNow:-60 * 60 * 24 * 2]];
NSDate *dayAfterTomorrow = [cal dateFromComponents:components];
components = [cal components:calendarUnit fromDate:self];
NSDate *otherDate = [cal dateFromComponents:components];
if([dayAfterTomorrow isEqualToDate:otherDate]) {
return YES;
}
return NO;
}
// 判断是否是昨天
- (BOOL)isYesterDay
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit);
NSDateComponents *components = [cal components:calendarUnit fromDate:[NSDate dateWithTimeIntervalSinceNow:-60 * 60 * 24]];
NSDate *today = [cal dateFromComponents:components];
components = [cal components:calendarUnit fromDate:self];
NSDate *otherDate = [cal dateFromComponents:components];
if([today isEqualToDate:otherDate]) {
return YES;
}
return NO;
}
// 判断是否是今天
- (BOOL)isToday
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit);
NSDateComponents *components = [cal components:calendarUnit fromDate:[NSDate date]];
NSDate *today = [cal dateFromComponents:components];
components = [cal components:calendarUnit fromDate:self];
NSDate *otherDate = [cal dateFromComponents:components];
if([today isEqualToDate:otherDate]) {
return YES;
}
return NO;
}
// 判断是否是明天
- (BOOL)isTomorrow
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit);
NSDateComponents *components = [cal components:calendarUnit fromDate:[NSDate dateWithTimeIntervalSinceNow:60 * 60 * 24]];
NSDate *tomorrow = [cal dateFromComponents:components];
components = [cal components:calendarUnit fromDate:self];
NSDate *otherDate = [cal dateFromComponents:components];
if([tomorrow isEqualToDate:otherDate]) {
return YES;
}
return NO;
}
// 判断是否是后天
- (BOOL)isTheDayAfterTomorrow
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit);
NSDateComponents *components = [cal components:calendarUnit fromDate:[NSDate dateWithTimeIntervalSinceNow:60 * 60 * 24 * 2]];
NSDate *dayAfterTomorrow = [cal dateFromComponents:components];
components = [cal components:calendarUnit fromDate:self];
NSDate *otherDate = [cal dateFromComponents:components];
if([dayAfterTomorrow isEqualToDate:otherDate]) {
return YES;
}
return NO;
}
// 转换成年月日(其他补0)
- (NSDate *)convertDefinitionToDate
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSDate *dateConverted = [cal dateFromComponents:components];
return dateConverted;
}
// 转换标准时间
- (NSString *)convertToStandardDateFormat
{
// eg: 2014-01-03 19:36 星期五
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSInteger weekday = [components weekday];
NSString *weekdayStr = nil;
switch (weekday) {
case 1:
weekdayStr = @"星期日";
break;
case 2:
weekdayStr = @"星期一";
break;
case 3:
weekdayStr = @"星期二";
break;
case 4:
weekdayStr = @"星期三";
break;
case 5:
weekdayStr = @"星期四";
break;
case 6:
weekdayStr = @"星期五";
break;
case 7:
weekdayStr = @"星期六";
break;
default:
break;
}
NSString *standardDateFormatStr = [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d %@", (int)year, (int)month, (int)day, (int)hour, (int)minute, weekdayStr];
return standardDateFormatStr;
}
// 转换本星期标准时间
- (NSString *)convertToStandardThisWeekDateFormat
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSInteger weekday = [components weekday];
NSString *weekdayStr = nil;
switch (weekday) {
case 1:
weekdayStr = @"星期日";
break;
case 2:
weekdayStr = @"星期一";
break;
case 3:
weekdayStr = @"星期二";
break;
case 4:
weekdayStr = @"星期三";
break;
case 5:
weekdayStr = @"星期四";
break;
case 6:
weekdayStr = @"星期五";
break;
case 7:
weekdayStr = @"星期六";
break;
default:
return nil;
break;
}
NSString *standardThisWeekDateFormatStr = [NSString stringWithFormat:@"%@ %02d:%02d", weekdayStr, (int)hour, (int)minute];
return standardThisWeekDateFormatStr;
}
- (NSString *)convertToStandardTimeDateFormat
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSCalendarUnitHour
| NSCalendarUnitMinute);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSString *timeDateFormatStr = [NSString stringWithFormat:@"%02d:%02d", (int)hour, (int)minute];
return timeDateFormatStr;
}
- (NSString *)convertToStandardNormalDateFormat
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSString *dateFormatStr = [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d", (int)year, (int)month, (int)day, (int)hour, (int)minute];
return dateFormatStr;
}
// 转换成YYYY-MM-DD HH:MM:SS格式时间
- (NSString *)convertToStandardYYYYMMDDHHMMSSDateFormat
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSInteger second = [components second];
NSString *standardDateFormatStr = [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d", (int)year, (int)month, (int)day, (int)hour, (int)minute, (int)second];
return standardDateFormatStr;
}
- (NSString *)convertToYYYYMMDDHHMMSSDateFormat {
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSInteger second = [components second];
NSString *standardDateFormatStr = [NSString stringWithFormat:@"%04d%02d%02d%02d%02d%02d", (int)year, (int)month, (int)day, (int)hour, (int)minute, (int)second];
return standardDateFormatStr;
}
// 转换成YYYY-MM-DD
- (NSString *)convertToStandardYYYYMMDDDateFormat
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];
NSString *standardDateFormatStr = [NSString stringWithFormat:@"%04d-%02d-%02d", (int)year, (int)month, (int)day];
return standardDateFormatStr;
}
// 转换成标准前天、昨天、今天、明天、后天时间 今天 19:36
- (NSString *)convertToStandardRecentlyDateFormat
{
NSString *dateStr = nil;
if ([self isToday]) {
dateStr = @"今天";
} else if ([self isTomorrow]) {
dateStr = @"明天";
} else if ([self isTheDayAfterTomorrow]) {
dateStr = @"后天";
} else if ([self isYesterDay]) {
dateStr = @"昨天";
} else if ([self isTheDayBeforeYesterday]) {
dateStr = @"前天";
} else {
NSLog(@"类型错误:%s", __FUNCTION__);
return nil;
}
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSCalendarUnitHour
| NSCalendarUnitMinute);
NSDateComponents *components = [cal components:calendarUnit fromDate:self];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSString *todayDateFormatStr = [NSString stringWithFormat:@"%@ %02d:%02d", dateStr, (int)hour, (int)minute];
return todayDateFormatStr;
}
+ (NSDateComponents *)dateComponentsByDate:(NSDate *)date {
NSCalendar *calendar = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = NSYearCalendarUnit| NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit | NSWeekdayOrdinalCalendarUnit | NSWeekOfYearCalendarUnit;
return [calendar components:calendarUnit fromDate:date];
}
+ (int)weekdayByDate:(NSDate *)date {
return (int)[[self dateComponentsByDate:date] weekday];
}
+ (NSString *)weekdayInChineseByDate:(NSDate *)date {
NSString *name = nil;
NSInteger weekday = [NSDate weekdayByDate:date];
switch (weekday) {
case 1:
name = @"周日";
break;
case 2:
name = @"周一";
break;
case 3:
name = @"周二";
break;
case 4:
name = @"周三";
break;
case 5:
name = @"周四";
break;
case 6:
name = @"周五";
break;
case 7:
name = @"周六";
break;
default:
break;
}
return name;
}
+ (NSDate *)dateWithDays:(NSUInteger)days beforDate:(NSDate *)date {
NSTimeInterval interval = [date timeIntervalSinceReferenceDate] - 86400 * days;
return [NSDate dateWithTimeIntervalSinceReferenceDate:interval];
}
+ (NSDate *)dateWithDays:(NSUInteger)days afterDate:(NSDate *)date {
NSTimeInterval interval = [date timeIntervalSinceReferenceDate] + 86400 * days;
return [NSDate dateWithTimeIntervalSinceReferenceDate:interval];
}
+ (NSArray *)dayNamesAtDays:(NSInteger)days beforDate:(NSDate *)date {
NSMutableArray *names = [NSMutableArray array];
NSInteger currentMonthDay = [NSDate dayByDate:date];
for (int i = (int)days - 1; i >= currentMonthDay ; i--) {
NSDate *date = [NSDate dateWithDays:i beforDate:[NSDate date]];
NSInteger day = [NSDate dayByDate:date];
[names addObject:[NSString stringWithFormat:@"%d", (int)day]];
}
for (int i = (int)currentMonthDay - 1; i >= 0; i--) {
NSDate *date = [NSDate dateWithDays:i beforDate:[NSDate date]];
NSInteger day = [NSDate dayByDate:date];
[names addObject:[NSString stringWithFormat:@"%d", (int)day]];
}
return names;
}
+ (int)yearByDate:(NSDate *)date {
return (int)[[self dateComponentsByDate:date] year];
}
+ (int)monthByDate:(NSDate *)date {
return (int)[[self dateComponentsByDate:date] month];
}
+ (int)dayByDate:(NSDate *)date {
return (int)[[self dateComponentsByDate:date] day];
}
+ (int)weekOfYearByDate:(NSDate *)date {
return (int)[[self dateComponentsByDate:date] weekOfYear];
}
+(NSString *)getCurrentDateHHMM
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm"];
return [formatter stringFromDate:[NSDate date]];
}
+(NSString *)getCurrentDateYYYYMMDDHHMM
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyyMMdd HH:mm"];
return [formatter stringFromDate:[NSDate date]];
}
+(NSString *)getDateYYYYMMDD:(NSDate *)date
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyyMMdd"];
return [formatter stringFromDate:date];
}
+ (int)daysInMonthByDate:(NSDate *)date {
NSRange dayRange = [[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:date];
return (int)dayRange.length;
}
+ (NSString *)convertToyyyMMddHHmmssString:(NSDate *)date {
NSCalendar *cal = [NSCalendar currentCalendar];
NSCalendarUnit calendarUnit = ( NSEraCalendarUnit
| NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit
| NSCalendarUnitWeekday
| NSCalendarUnitHour
| NSCalendarUnitMinute
| NSCalendarUnitSecond);
NSDateComponents *components = [cal components:calendarUnit fromDate:date];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSInteger second = [components second];
NSString *dateFormatStr = [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d", (int)year, (int)month, (int)day, (int)hour, (int)minute, (int)second];
return dateFormatStr;
}
+ (NSDate *) convertDateFromString:(NSString *)dateString {
static NSDateFormatter *formatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
formatter = [[NSDateFormatter alloc] init];
});
[formatter setDateFormat:@"yyyy-MM-dd HH-mm-ss"];
NSDate *date=[formatter dateFromString:dateString];
return date;
}
+ (NSDate *)stringToDate:(NSString *)dateString {
static NSDateFormatter *formatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
formatter = [[NSDateFormatter alloc] init];
});
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date=[formatter dateFromString:dateString];
return date;
}
@end
iOS 关于时间天数星期月份的总结的更多相关文章
- atitit.GMT UTC Catitit.GMT UTC CST DST CET 星期 月份 节日 时间的不同本质and起源
atitit.GMT UTC Catitit.GMT UTC CST DST CET 星期 月份 节日 时间的不同本质and起源 1. GMT(Greenwich Mean Time)是格林尼治平时 ...
- oracle 计算两个时间之间的月份差,相差几个星期,相差多少天
相差多少天: sysdate-to_date('1991-01-01','YYYY-MM-DD'))<7 and (sysdate-to_date('1991=01=01','YYYY-MM ...
- iOS - 获取当前时间日期星期几
//获取当前时间日期星期 - (NSString *)getCurrentTimeAndWeekDay { NSArray * arrWeek=[NSArray arrayWithObjects:@& ...
- [VC++]用CTime类得到当前日期、时间、星期,格式化(详细讲解)
用CTime类得到当前日期.时间.星期,格式化(详细讲解)2009/05/12 09:48 A.M.① 定义一个CTime类对象 CTime time; ② 得到当前时间 time = CTime:: ...
- iOS关于时间的处理
转自:iOS关于时间的处理 做App避免不了要和时间打交道,关于时间的处理,里面有不少门道,远不是一行API调用,获取当前系统时间这么简单.我们需要了解与时间相关的各种API之间的差别,再因场景而异去 ...
- 实现iOS长时间后台的两种方法:Audiosession和VOIP(转)
分类: Iphone2013-01-24 14:03 986人阅读 评论(0) 收藏 举报 我们知道iOS开启后台任务后可以获得最多600秒的执行时间,而一些需要在后台下载或者与服务器保持连接的App ...
- 根据日期字符串获取星期几,日期获取星期,时间获取星期,js获取星期
根据日期字符串获取星期几,日期获取星期,时间获取星期,js获取星期 >>>>>>>>>>>>>>>>&g ...
- MySQL里求给定的时间是所在月份的第几个礼拜
Share 一个昨天写的函数. 目的是求给定的时间是所在月份的第几个礼拜. DELIMITER $$ USE `t_girl`$$ DROP FUNCTION IF EXISTS `weekofmon ...
- PHP 获取两个时间之间的月份
## 获取两个时间之间的间距时间 $s = '2017-02-05'; $e = '2017-07-20'; $start = new \DateTime($s); $end = new \DateT ...
随机推荐
- 小型网站MYSQL问题二:Percona Xtrabackup实现数据库备份和恢复
1.安装软件仓库(不要问我为什么不用源码安装,好吧,其实我懒.) 1 2 3 4 5 6 7 8 wget https://www.percona.com/downloads/percona-rele ...
- Linux系统——ssh-key连接原理
SSH是一种客户端连接,在Linux服务器下通过远程的方式将本地电脑连接到对方的电脑上. 远程连接的方式: (1)telnet命令(为明文传输,不安全) (2)(2)SSH(加密传输,安全) 操作的两 ...
- SpringData环境搭建代码编写
首先我们在前面的两节已经了解了SpringData是干什么用的?那我们从这节开始我们就开始编码测试SpringData. 1:首先我们从配置文件开始,我们首先需要写一个连接数据库的文件db.prope ...
- cocos代码研究(9)ProgressTimer类学习笔记
理论部分 ProgressTimer是Node的子类. 该类根据百分比来渲染显示内部的Sprite对象. 变化方向包括径向,水平或者垂直方向. 代码部分 Type getType () const获取 ...
- #C++初学记录 (第一次测试)(A - 复习时间 )
练习题目一 (A-复习时间) 为了能过个好年,xhd开始复习了,于是每天晚上背着书往教室跑.xhd复习有个习惯,在复习完一门课后,他总是挑一门更简单的课进行复习,而他复习这门课的效率为两门课的难度差的 ...
- Python:笔记(7)——yield关键字
Python:笔记(7)——yield关键字 yield与生成器 所谓生成器是一个函数,它可以生成一个值的序列,以便在迭代中使用.函数使用yield关键字可以定义生成器对象. 一个例子 我们调用该函数 ...
- viewport 编写 iPhone Friendly 的 Web 应用程序
在了解到iPhone的一些常见布局法后,我们就可以开始着手编写一个真正能在iPhone上跑的页面了.小声说一句,之前我说要布局讨论完了,要进入交互逻辑开发,后来细心一想发现不行,有些东西不讲的话将会对 ...
- Ubuntu 系统下暴力卸载 MySQL
一.概述 MySQL 出问题了,正常的 start.stop 不起作用. apt-get remove mysql-server apt-get remove mysql-client 上面这些命令不 ...
- Redis快速入门之简介
一.Redis是什么? Redis 是一个开源(BSD许可)基于内存数据结构存储系统,它可以用作数据库.缓存和消息中间件. 它支持多种类型的数据结构,如字符串(strings), 散列(hashes) ...
- logstash收集Nginx日志,转换为JSON格式
Nginx日志处理为JSON格式,并放置在http区块: log_format json '{"@timestamp":"$time_iso8601",' '& ...