How to show Month and also weekday in three letters from date

Hello I am getting a date from server like this

2016-02-10

and I want to show a date on my view like this

 TUE, 10 FEB 2016

How can I do this

here is my code of getting a date

let departureDate  = (((dict["\(indexPath.item)"] as?NSDictionary)!["Trip"] as?NSDictionary)!["departure_date"] as?NSString)! as String

Answers


do like

//create dateformatter
let dateFormatter2 = NSDateFormatter()

// set your dateformat intially whatever u get from server or local
                          //2016-02-10
dateFormatter2.dateFormat = "yyyy-MM-dd"

// convert your string to date
let date2 = dateFormatter2.dateFromString(departureDate as String)

 // create another dateformat for what output u need at final
                           // TUE, 10 FEB 2016
 dateFormatter2.dateFormat = "EEE, dd MMM yyyy"
 // again convert the date to string again 
 let finaldate = dateFormatter2.stringFromDate(date2!).uppercaseString

iPhone format strings are in Unicode format.


Need Your Help

VBoxManage: error: The specified user was not able to logon on guest

virtual-machine virtualbox vbox

I'm setting up vm to receive files from a linux host. I can't seem to figure out why I can't logon to the vm guest using vboxmanage. I've included details about the vm and the error below.

EntityRule in subgrid on custom entity not working

dynamics-crm-2011 dynamics-crm ribbon

I tried to add a button to connection subgrid ribbon. This button should only be visible if the primary entity equals 'new_visitreport'.