Q: Swift string format to hex cutting off first two bytes I'm trying to convert a timestamp to hexidecimal string with a set length of 12 characters such as 006AC2291E37. Here are the two ways I've tried to implement this:
var curTime = NSDate().timeIntervalSinceReferenceDate*1000

var hex = String(Int(curTime), radix: 16)  // "6AC2291E37"

println(String(format: "%012X", Int(curTime)))  // "0000C2291E37"

As you can see by the outputs, the seconds version cuts off the first two digits of the hex timestamp, but has the correct format. The first version has the correct timestamp but incorrect format. 
How should this be implemented?

A: Very simple:
String(format: "%012lX", Int(curTime))

It cuts it off because the default for 'X' is an unsigned 32 bit integer, but in your example a 64 bit integer is used.
Also why are you multiplying this time interval by 1000?? This doesn't make any sense. 
