swift 時間操作類

2021-06-27 10:39:40 字數 1639 閱讀 8271

//

// jdateutil.swift

// meetr

//// created by yktx on 14/12/4.

//import foundation

public extension nsdate

// 現在的字元傳 格式

var stringnowtime:nsstring

// 現在的 時間格式

var datenowtime:nsdate

//今天的時間格式

var datetodaytime:nsdate

//今天的時間戳格式

var unixtodaytime:nstimeinterval

//今天的字串格式

var stringtodaytime:nsstring

// 時間戳 轉 時間

func unixtodate(unixtime:nstimeinterval) -> nsdate

// 時間 轉 時間戳

func datetounix(datetime:nsdate) -> nstimeinterval

// 時間 轉 時間戳

func datetostring(datetime:nsdate,dateformat:nsstring?) -> nsstring

formatter.dateformat = dateformat == nil ? dateforma : dateformat

return formatter.stringfromdate(datetime)

}// 時間戳 轉 時間字串

func unixtostring(unixtime:nstimeinterval,dateformat:nsstring?) -> nsstring

formatter.dateformat = dateformat == nil ? dateforma : dateformat

return formatter.stringfromdate(date)

}// 字串 轉 時間

func stringtodate(stringtime:nsstring,dateformat:nsstring?) -> nsdate

outputformatter.dateformat = dateformat == nil ? dateforma : dateformat

return outputformatter.datefromstring(stringtime)!

}// 字串 轉 時間戳

func stringtounix(stringtime:nsstring) -> nstimeinterval

//調整日期

func adjustdate(date:nsdate,intervalday:nsinteger) -> nsdate

func timestdate(intidate:nsdate) ->nsstringelse

}else if(isyestoday == yesterday)elseelse

if(current.hasprefix("year"))else

}}else if(timedistance >= 60)else

}}

C 時間操作類

using system namespace dotnet.utilities mmdd separator,separator return dt.tostring tem else 將時間格式化成 時分秒 的形式,如果時間為null,返回當前系統時間 public string getforma...

操作時間的工具類

public class dateutil else return iscurandnext 判斷當前是乙個星期中的第幾天 第一天是星期一 最後一天是星期日 public static int getweekofcurdate return w 將時間字串轉換成date public static ...

js時間類操作整理

date物件 常見物件方法 var d newdate 當前獲取當前時間 tue feb 09 2021 13 21 03 gmt 0800 中國標準時間 d.getfullyear 根據時間獲取 年 2021 d.getmonth 根據時間獲取 月 0 11 對應 1到12月 1 對應2月 d.g...