Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AppleScript(或swift)将小时添加到时间_Swift_Date_Applescript - Fatal编程技术网

AppleScript(或swift)将小时添加到时间

AppleScript(或swift)将小时添加到时间,swift,date,applescript,Swift,Date,Applescript,我正在尝试将8小时添加到日期(从剪贴板) 但这不是预期的效果,我有错误 无法将“06/22/2015 08:15:27”转换为类型编号。您需要选择小时作为单个变量,如下所示: set currentDate to current date set newHour to ((hours of currentDate) + 8) 你也可以使用它几天,几分钟和几秒钟 这会奏效的。然后,您可以使用这些变量构造一个新的日期,以便在显示对话框中使用 注:如果newHour变量大于24小时,不要忘记更改日

我正在尝试将8小时添加到日期(从剪贴板)

但这不是预期的效果,我有错误
无法将“06/22/2015 08:15:27”转换为类型编号。

您需要选择小时作为单个变量,如下所示:

set currentDate to current date

set newHour to ((hours of currentDate) + 8)
你也可以使用它几天,几分钟和几秒钟

这会奏效的。然后,您可以使用这些变量构造一个新的日期,以便在
显示对话框中使用

注:如果
newHour
变量大于24小时,不要忘记更改日期

编辑

将日期设置到剪贴板的操作如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate
获取当前剪贴板并将其添加到变量如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate

我希望这有帮助

您需要选择小时作为单个变量,如下所示:

set currentDate to current date

set newHour to ((hours of currentDate) + 8)
你也可以使用它几天,几分钟和几秒钟

这会奏效的。然后,您可以使用这些变量构造一个新的日期,以便在
显示对话框中使用

注:如果
newHour
变量大于24小时,不要忘记更改日期

编辑

将日期设置到剪贴板的操作如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate
获取当前剪贴板并将其添加到变量如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate

我希望这有帮助

您需要选择小时作为单个变量,如下所示:

set currentDate to current date

set newHour to ((hours of currentDate) + 8)
你也可以使用它几天,几分钟和几秒钟

这会奏效的。然后,您可以使用这些变量构造一个新的日期,以便在
显示对话框中使用

注:如果
newHour
变量大于24小时,不要忘记更改日期

编辑

将日期设置到剪贴板的操作如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate
获取当前剪贴板并将其添加到变量如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate

我希望这有帮助

您需要选择小时作为单个变量,如下所示:

set currentDate to current date

set newHour to ((hours of currentDate) + 8)
你也可以使用它几天,几分钟和几秒钟

这会奏效的。然后,您可以使用这些变量构造一个新的日期,以便在
显示对话框中使用

注:如果
newHour
变量大于24小时,不要忘记更改日期

编辑

将日期设置到剪贴板的操作如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate
获取当前剪贴板并将其添加到变量如下:

set currentDate to current date
set the clipboard to currentDate as Unicode text
set currentDate to get the clipboard
display dialog currentDate

我希望这有帮助

在Swift中,您可以通过在
NSDate
对象上添加时间间隔来调用
date。
时间间隔以秒为单位

yourDate.dateByAddingTimeInterval(8 * 60 * 60)
如果要添加另一个方法以直接添加8小时,可以定义扩展:

extension NSDate {
    func addEightHours() -> NSDate {
        return self.dateByAddingTimeInterval(8 * 60 * 60)
    }
}

在Swift中,您可以通过在
NSDate
对象上添加时间间隔来调用
date。
时间间隔以秒为单位

yourDate.dateByAddingTimeInterval(8 * 60 * 60)
如果要添加另一个方法以直接添加8小时,可以定义扩展:

extension NSDate {
    func addEightHours() -> NSDate {
        return self.dateByAddingTimeInterval(8 * 60 * 60)
    }
}

在Swift中,您可以通过在
NSDate
对象上添加时间间隔来调用
date。
时间间隔以秒为单位

yourDate.dateByAddingTimeInterval(8 * 60 * 60)
如果要添加另一个方法以直接添加8小时,可以定义扩展:

extension NSDate {
    func addEightHours() -> NSDate {
        return self.dateByAddingTimeInterval(8 * 60 * 60)
    }
}

在Swift中,您可以通过在
NSDate
对象上添加时间间隔来调用
date。
时间间隔以秒为单位

yourDate.dateByAddingTimeInterval(8 * 60 * 60)
如果要添加另一个方法以直接添加8小时,可以定义扩展:

extension NSDate {
    func addEightHours() -> NSDate {
        return self.dateByAddingTimeInterval(8 * 60 * 60)
    }
}

这个问题与Swift有什么关系?这个问题与Swift有什么关系?这个问题与Swift有什么关系?你好,这很有帮助,但是我不想在当前日期上加8小时,而是在剪贴板中保存的日期(过去的事件)后加8小时我不确定如何将剪贴板设置为日期,这样我就可以添加8小时的Hi NGAFD,这很有帮助,但是我不想将8小时添加到当前日期,而是从剪贴板中保存的日期(过去的事件)添加8小时。我不确定如何将剪贴板设置为日期,这样我就可以添加8小时的Hi NGAFD,这很有帮助,但是,我没有尝试将8小时添加到当前日期,而是从剪贴板中保存的日期(过去的事件)添加8小时。我不确定如何将剪贴板设置为日期,以便可以添加8小时。这很有帮助,但是我没有尝试将8小时添加到当前日期,而是从剪贴板中保存的日期(过去的事件)添加8小时我不知道如何设置剪贴板作为一个日期,这样我可以添加这8小时