Latest 1.0.4
Homepage https://github.com/HirokiUmatani/DateUnixConvertor-Swift
License MIT
Platforms ios 8.0, requires ARC
Authors

DateUnixConvertor-Swift GitHub license CocoaPods CocoaPods

====

Overview

Convert
This Library can convert to NSDate,UnixTime or String.
NSDate -> String
NSDate -> UnixTime
UnixTime ->String

String -> NSDate
String -> UnixTime
UnixTime -> NSDate

Installation


platform :ios, '8.0'
use_frameworks!
target 'YOUR_PROJECT_NAME' do
pod "DateUnixConvertor-Swift"
end

Usage

□ Import


import DateUnixConvertor_Swift

□ sample

/**
         convert from NSDate to String or Unix Time
         */
        let NOW_DATE = NSDate()
        let OUTPUT_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"

        let date_string:String = DateUnixConvertor.convertStringFromDate(NOW_DATE, format: OUTPUT_FORMAT)

        NSLog("date -> string :%@",date_string);

        let date_time:Double = DateUnixConvertor .convertUnixTimeFromDate(NOW_DATE)
        NSLog("date -> unix_time :%f",date_time);

        let time_str:String = DateUnixConvertor.convertStringFromUnixTime(date_time, format: OUTPUT_FORMAT)
        NSLog("unix_time -> string :%@",time_str);

        /**
         convert from String to NSDate or UnixTime
         */
        let TEST_DATE:String = "1234-05-06 01:23:45.678"
        let INPUT_FORMAT:String = "yyyy-MM-dd HH:mm:ss.SSS"

        let str_date:NSDate = DateUnixConvertor .convertDateFromString(TEST_DATE, format: INPUT_FORMAT)
        NSLog("string -> date :%@",str_date);

        let str_time:Double = DateUnixConvertor.convertUnixTimeFromString(TEST_DATE, format: INPUT_FORMAT)

        NSLog("string -> unix_time :%f",str_time);

        let time_date:NSDate = DateUnixConvertor.convertDateFromUnixTime(str_time)

        NSLog("unix_time -> date :%@",time_date);

Documents

library document

Licence

MIT

Author

GitHub
CocoaPod
FaceBook
Twitter

Latest podspec

{
    "name": "DateUnixConvertor-Swift",
    "version": "1.0.4",
    "platforms": {
        "ios": "8.0"
    },
    "license": "MIT",
    "summary": "This Library can convert to NSDate,UnixTime or String. NSDate -> String",
    "homepage": "https://github.com/HirokiUmatani/DateUnixConvertor-Swift",
    "authors": {
        "HirokiUmatani": "[email protected]"
    },
    "source": {
        "git": "https://github.com/HirokiUmatani/DateUnixConvertor-Swift.git",
        "tag": "1.0.4"
    },
    "source_files": "DateUnixConvertor-swift/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This