         
         if diffStart == NSComparisonResult.OrderedAscending && diffEnd == NSComparisonResult.OrderedDescending{
             if diffStartTime == NSComparisonResult.OrderedDescending && diffEndTime == NSComparisonResult.OrderedAscending{
-                setNotificationTimestamp(geo["id"].asString!,date: currentDate)
+                var currentDateFromString = convertDateToString(currentDate)
+                setNotificationTimestamp(geo["id"].asString!,date: currentDateFromString!)
                 return true
             }
             else{

    }
    
    func checkRateLimit(geo: JSON) -> Bool{
        var date = NSDate()
        var previousDate = getNotificationTimestamp(geo["id"].asString!)
        var rateLimit = geo["period_milliseconds"].asString!
        
        if previousDate == "empty" {
            //setNotificationTimestamp(geo["id"].asString!, date: date)
            return true
        } else {
        
            let dateFormatter = NSDateFormatter()
            dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss.SSSSSxxx"
            let convertedPreviousDate = dateFormatter.dateFromString(previousDate!)
        
            let elapsedTime = NSDate().timeIntervalSinceDate(convertedPreviousDate!)
            
            log("ADDDDD: \(elapsedTime)")
            
            return false
        }
    }
    
    func setNotificationTimestamp(regionId: String,date: NSDate){
        let defaults = NSUserDefaults.standardUserDefaults()
        defaults.setObject(date, forKey: regionId)
    }
    
    func getNotificationTimestamp(regionId: String) -> String?{
        log("\(regionId)")
        let defaults = NSUserDefaults.standardUserDefaults()
        let variable = defaults.objectForKey("\(regionId)") as? String
        log("\(variable)")
        if variable != nil{
            return variable
        }
        else{
            return "empty"
        }
    }
}

    func notifyAbout(geo: JSON) {
        log("Creating notification")
        
        //Qui chiamo il controllo dei millisecondi
        var tryVar : Bool = checkRateLimit(geo)
        
        if tryVar == true {
            if validateTime(geo) == true{
                var notification = UILocalNotification()
                notification.timeZone = NSTimeZone.defaultTimeZone()
                var dateTime = NSDate()
                notification.fireDate = dateTime
                notification.alertBody = geo["notification"]["text"].asString!
                UIApplication.sharedApplication().scheduleLocalNotification(notification)
            }
        }
    }
    
