iOS获取某个日期后n个月的日期
-(NSDate *)getPriousorLaterDateFromDate:(NSDate *)date withMonth:(NSInteger)month { NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setMonth:month]; NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDate *mDate = [calender dateByAddingComponents:comps toDate:date options:]; return mDate; }
- (NSDate *)getLaterDateFromDate:(NSDate *)date withYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day {
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDateComponents *comps = nil; comps = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:date]; NSDateComponents *adcomps = [[NSDateComponents alloc] init]; [adcomps setYear:year]; [adcomps setMonth:month]; [adcomps setDay:day]; NSDate *newdate = [calendar dateByAddingComponents:adcomps toDate:date options:]; return newdate;
}
iOS获取某个日期后n个月的日期的更多相关文章
- SQL Server 获取最后一天(指定时间的月最后一天日期)
/* author OceanHo @ 2015-10-23 10:14:21 获取指定时间字符串指定日期的月最后一天日期 */ IF OBJECT_ID('get_LastDayDate') IS ...
- js时间比较,获取n天后(前)的日期
<html> <head> <meta http-equiv="Content-Type" content="textml; charset ...
- iOS获取设备卸载后不变的UUID
1.首先导入系统库Security.framework 2.创建文件SFHFKeychainUtils.h如下(复制即可): @interface SFHFKeychainUtils : NSObje ...
- Laravel Carbon获取 某个时间后N个月的时间
$time = "2020-11-20 00:00:00"; $res = (new Carbon)->setTimeFromTimeString($time)->ad ...
- js获取给定月份的N个月后的日期
1.在讲js获取给定月份的N个月后的日期之前,小颖先给大家讲下getFullYear().getYear()的区别. ①getYear() var d = new Date() console.log ...
- JAVA获取当前日期指定月份后(多少个月后)的日期
环境要求:使用jdk1.8 package com.date; import java.text.ParseException; import java.text.SimpleDateFormat; ...
- python获取当前日期前后N天或N月的日期
# -*- coding: utf-8 -*- '''获取当前日期前后N天或N月的日期''' from time import strftime, localtime from datetime im ...
- iOS 获取公历、农历日期的年月日
iOS 获取公历.农历日期的年月日 介绍三种方法获取 Date (NSDate) 的年月日. 用 date 表示当前日期.测试日期为公历 2017 年 2 月 5 日,农历丁酉年,鸡年,正月初九. l ...
- python里如何获取当前日期前后N天或N月的日期
#!/usr/bin/python#_*_ coding:UTF-8_*_ import timeimport datetimeimport mathimport calendar ''' time. ...
随机推荐
- LeetCode300. Longest Increasing Subsequence
Description Given an unsorted array of integers, find the length of longest increasing subsequence. ...
- LeetCode递归 -2(Recursion) 培训专题 讲解文章翻译 (附链接) (2019-04-09 15:50)
递归 - 空间复杂度 在本文中, 我们将讨论如何分析递归算法的空间复杂度. 在计算递归算法的空间复杂度时,最需要考虑的两个部分就是: 递归相关空间 (recursion related space) ...
- 检测进程不存在自动重启shell脚本
#!/bin/bash WORKDIR="/usr/local/gse/gseagent" [[ -d $WORKDIR ]] && { if ! ps aux|g ...
- weixin oauth 授权
1. 先了解下请求授权页面的构造方式: https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_u ...
- python tensorflow方法手记
Variable tf.Variable(initializer, name)给变量取名initializer是初始化参数,可以有tf.random_normal,tf.constant等.name就 ...
- 43、android:screenOrientation
android:screenOrientationThe orientation of the activity's display on the device. The value can be a ...
- node.js调用函数
首先EditPlus编辑器,打开新建的文本文档,另存为副本 调用函数分为调用本地函数,和其他文件的函数 1.调用本地函数 var http = require('http'); http.create ...
- poj 3590(dp 置换)
题目的意思是对于序列1,2,...,n.要你给出一种字典序最小的置换使得经过X次后变成最初状态,且要求最小的X最大. 通过理解置换的性质,问题可以等价于求x1,x2,..,xn 使得x1+x2+... ...
- 【BZOJ2064】分裂 状压DP
[BZOJ2064]分裂 Description 背景:和久必分,分久必和...题目描述:中国历史上上分分和和次数非常多..通读中国历史的WJMZBMR表示毫无压力.同时经常搞OI的他把这个变成了一个 ...
- ibatis 大于等于小于等于的写法
在ibatis的sql语句xml配置文件中,写sql语句会经常用到大于等于小于等于等等符号.网上搜罗了一些写法,大致有3种: 其实就是xml特殊符号,转义的方式. < < > > ...