NSDateFormatter用法

手把手教你用HI3516CV610搭建智能安防摄像头(附完整开发资料) 本文详细介绍了基于海思HI3516CV610 SOC搭建智能安防摄像头的完整开发流程,包括硬件选型、系统架构设计、开发环境搭建、智能分析功能开发及系统调优。通过实战案例,展示了如何利用内置NPU实现人形检测和异常行为分析,并提供了量产测试方案,帮助开发者快速完成智能摄像头项目。 阅读详情

NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init]autorelease];

[dateFormatter setAMSymbol:@"AM"];

[dateFormatter setPMSymbol:@"PM"];

[dateFormatter setDateFormat:@"yyyy年MM月dd日 hh:mmaaa"];

NSDate *date = [NSDate date];

NSString * s = [dateFormatter stringFromDate:date];

显示效果为:2012年09月01日 03:49PM



下面附上几个格式:这个是从Cocoachina上来的

yyyy:MM:dd G 'at' HH:mm:ss zzz            1996.07.10 AD at 15:08:56 PDT

EEE, MMM d, "yy                                         Wed,july 10, '99

h:mm a                                                     12:08 PM

hh 'o"clock' a,zzzz                                      12 o'clock PM, Pacific Daylight Time

K:mm a, z                                                 0:00 PM, PST

yyyyy,MMMM.dd GGG hh:mm aaa                01996.july.10 AD 12:08 PM



下面是得到当前的年,月,日,时,分,秒。

NSCalendar *cal = [NSCalendar currentCalendar];

unsigned int unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;

NSDateComponents *dd = [cal components:unitFlags fromDate:date]; 

int y = [dd year];

int m = [dd month];

int d = [dd day];

int h = [dd hour];

int m = [dd minute];

int s = [dd second];


iOS计时器

 NSDate *date1 = [NSDate date];
    sleep(2);
    NSDate *date2 = [NSDate date];
    //怎样将date2与date1的时间间隔表示为:00:00:10 的形式
   NSTimeInterval time = [date2 timeIntervalSinceDate:date1];
    NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:time];
    
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"HH:mm:ss"];
    NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    [df setTimeZone:gmt];
    NSString *str = [df stringFromDate:date];
    NSLog(@"%@",str);
    //结果:08:00:10



【异常】Claude Code 第三方API 400报错(thinking type should be enabled or disabled)解决方案 摘要: Claude Code接入第三方API端点时出现400参数错误,主要因新版默认启用的Adaptive Thinking功能与旧版接口参数格式不兼容(需thinking: {type: "adaptive"},但第三方仅支持布尔值)。解决方案为修改本地settings.json配置文件,添加"CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"环境变量并重启客户端,即可恢复思考模式功能。Adaptive Th 阅读详情

相关推荐

FLUENT UDF编译及蒸发冷凝相关问题

蒸发冷凝与相间传质

weixin_48029137的博客 1万+

NSDateFormatter 获取上下午

转载自:http://www.cnblogs.com/pengyingh/articles/2354343.html NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init]autorelease]; [dateFormatter setAMSymbol:@"AM"]; [dateFormatter s

沸腾的泪水的专栏 3073

YOLOv8 TensorRT C++部署实战详解:从XMake构建到推理流水线

本项目实现了一个基于YOLOv8和TensorRT的高性能火灾烟雾检测系统,具有以下核心特点: 技术架构:采用TensorRT 8.6+进行GPU加速推理,结合CUDA 12.1和OpenCV 4.8+,实现高效计算机视觉处理。系统使用XMake替代CMake构建,配置更简洁高效。

hscing的博客 1065

NSDateFormatter使用总结

+ (int)getDateYearStr:(NSDate *)date { NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease]; [dateFormat setDateFormat:@"yyyy"]; NSString *dateString = [dateFormat st

宁静致远 2161

论文阅读: 2024 ICLR AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models

AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models这篇论文名为“AUTODAN: GENERATING STEALTHY JAILBREAK PROMPTS ON ALIGNED LARGE LANGUAGE MODELS”,主要研究大语言模型(LLMs)的越狱攻击问题,提出了一种名为AutoDAN的新方法,能自动生成隐蔽的越狱提示,具体内容如下:

CSPhD-winston的博客 1177

如何理解下一代ERP 即:华为MetaERP

如何理解下一代ERP 即:华为MetaERP 华为的 MetaERP核心定位: 华为MetaERP是华为公司自主研发的下一代企业核心商业管理系统。它不仅仅是一个传统的ERP(企业资源规划)系统,更是一个面向未来、基于云原生、AI驱动、安全可信的企业核心管理平台。

金牌架构师 1142

NSDateFormatter格式详细列表一览

感谢原作者:http://www.cnblogs.com/xinus/archive/2012/10/29/NSDateFormatter_samples.html 前言:iOS开发中NSDateFormatter是一个很常用的类,用于格式化NSDate对象,支持本地化的信息。与时间相关的功能还可能会用到NSDateComponents类和NSCalendar类等。本文主要列出N

NewJerryj的专栏 2508

【MATLAB例程】三维下的IMM(交互式多模型),模型使用CV(匀速)和CA(匀加速),滤波使用EKF。附完整代码

CV模型:状态包含位置、速度和零加速度(9维状态),状态转移矩阵忽略加速度项CA模型:完整包含位置、速度和加速度(9维状态),状态转移矩阵包含二次项过程噪声矩阵Q分别根据两种模型的运动特性推导。

985工科博士毕业,专攻定位、导航和滤波等算法研究。从业10年,主要使用MATLAB 560

NSDateFormatter 'YYYY' 和 'yyyy' 的区别

今天刷微博的时候看到这个: 立马就想到了BK项目今天feedback回来的bug,运行了大半年好好的都没有啥问题,今天突然间黑屏了,debug后才发现,NSDateFormatter 的时候时间变成2015年了,擦,今天还是2014年啊亲!所以导致create preform的时候出现了问题。 Google了之后才发现是在格式化的时候由YYYY导致引起的,改回yyyy就好了。具体区别:

chaoyuan899的专栏 1万+

mojoPortal 路径穿越漏洞复现(CVE-2025-28367)(附脚本)

 在 mojoPortal CMS 版本 <=2.9.0.1 中发现了一个导致 ViewState 反序列化的目录遍历漏洞。通过利用此问题,未经身份验证的攻击者可以泄露 Web 根目录中的敏感文件,包括应用程序的文件。此配置文件包含用于验证和解密 ViewState 数据的文件。知道此密钥后,网络攻击者可以构建恶意 ViewState 有效负载,从而导致在底层服务器上执行远程代码。(CVE-2025-28367)

iSee857的博客 500

Codex 调试记录获取完全指南:日志查看、工具调用与实战排查教程

本文主要介绍了Codex 调试记录获取完全指南:日志查看、工具调用与实战排查教程,希望能对使用Codex的同学们有所帮助。 文章目录 1. 背景 2. 实战教程

weixin_43178406的博客 6万+

NSDateFormatter的用法

今天有幸来到Imagination开发者大会。听了几位美国大佬和英国大佬的描述,顿时感觉他们的技术生活是非常不一样的。昨天还办了一张健康证,想去做餐饮,现在想想,还是坚持一条道好了。太多的精力分散,会让你学业不专的,以后做事情还是不要头脑一热了。。    言归正传。    NSDateFormatter是日期格式转换器。 NSDateFormatter *dateFormatter = [[

tanglimei6313的专栏 685

【txt文本加密】使用 cryptography 库实现加密和解密

cryptography 库是一个强大的 Python 库,用于实现加密和解密功能。它提供了各种加密算法,包括对称加密、非对称加密、哈希函数等。

📷 图像处理践行者 | 传统算法 · 深度学习 · 多模态 | 分享实战经验与技术洞见,探索从像素到智能的无限可能。 2666

NSDateFormatter

前言:iOS开发中NSDateFormatter是一个很常用的类,用于格式化NSDate对象,支持本地化的信息。与时间相关的功能还可能会用到NSDateComponents类和NSCalendar类等。本文主要列出NSDateFormatter常见用法。  NSDate对象包含两个部分,日期(Date)和时间(Time)。格式化的时间字符串主要也是针对日期和时间的。[以下代码中开启了AR

Ruansf的专栏 2064

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

NSDateFormatter相关整理

今天在项目中碰到了NSDateFormatter的相关问题,在网上看了一些方法,觉得比较简单,就做一个简单的整理吧! Formatter译为格式,相应的NSDateFormatter就相当于是NSDate的转换类,将NSDate转换为另一种格式,或转换回来。NSDate没有自己的输出,需要借助NSDateFormatter以相应格式输出。这差不多就是NSDateFormatter的作用了吧。常用

Han_jihong的博客 632

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

NSDateFormatter用法:

日期格式化是最基本的了,就是那些套路,下面列一下: NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init]autorelease]; [dateFormatter setAMSymbol:@"AM"]; [dateFormatter setPMSymbol:@"PM"]; [dateFo

石头记 824

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

NSDateFormatter的使用

//实例化一个NSDateFormatter对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //设定时间格式,这里可以设置成自己需要的格式 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; //用[NSDate date]

yesjava的专栏 703

关于NSDateFormatter的线程安全问题

今天闲逛,突然捕获一个帖子说NSDateFormatter线程不安全,为了线程安全最好每个线程用自己的对象,如果需要用到的话

zskm001的博客 977

NSDateFormatter 基本用法

前言:iOS开发中NSDateFormatter是一个很常用的类,用于格式化NSDate对象,支持本地化的信息。与时间相关的功能还可能会用到NSDateComponents类和NSCalendar类等。本文主要列出NSDateFormatter常见用法。 NSDate对象包含两个部分,日期(Date)和时间(Time)。格式化的时间字符串主要也是针对日期和时间的。[以下代码中开启了ARC,...

weixin_34380781的博客 190

NSDateFormatter formats

在开发iOS的应用时要用到时间的显示,并且在不同的情况下显示不同的格式,苹果提供了NSDateFormatter这个类来进行设置,但是苹果官方文档上对NSDateFormatter的格式串好像没详讲, 或许有吧,毕竟苹果的资料算是很全了。但我找了一下没找到,每次使用时都是用谷歌摸索,找找例子抄下来改改。 后来搜索时看见说这是unicode标准,并且给出了一个网址:http://uni

zwkm6936367的专栏 795

NSDateFormatter之性能优化

NSDateFormatter之性能优化NSDateFormatter在开发过程使用算是频繁的,但是过度的创建NSDateFormatter用于NSDate与NSString之间转换,会导致App卡顿(特别是Cell上使用),打开Profile工具查一下性能,你会发现这种操作占CPU比例是非常高的。据官方NSDateFormatter官方文档说法,创建NSDateFormatter代价是比较高的,如

BabyStyles的博客 1387

NSDateFormatter格式汇总

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 初始化了一个NSDateFormatter变量后,对其调用setDateFormat方法,各种格式及运行结果如下: 1.我们最习惯的。 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss EEEE"]...

184

iOS开发--NSDateFormatter

NSDate对象包含两个部分,日期(Date)和时间(Time)。格式化的时间字符串主要也是针对日期和时间的 1、基础用法 1 NSDate* now = [NSDate date]; 2 NSDateFormatter* fmt = [[NSDateFormatter alloc] init]; 3 fmt.dateStyle = kCFDateFormatterShort...

177

NSDate与NSDateFormatter

1.NSDateFormatter配合NSDate与NSString之间的转化   NSDateFormatter有下面2个方法:   - (NSString *)stringFromDate:(NSDate*)date;//NSDate转NSString   - (NSDate *)dateFromString:(NSString*)string;//NSString转NSDate

The Life with iOS 971
上一篇: QQ空间背景音乐 链接制作
下一篇: Xcode不提示,不高亮 解决办法
focusjava
博客等级 码龄14年 127粉丝 528原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值