Help us understand the problem. What is going on with this article?

AppleScriptで現在日時の文字列を取得する

More than 5 years have passed since last update.

現在の日時オブジェクトを取得(AppleScript エディタで実行)

current date

結果

date "2014年8月8日金曜日 7:10:15"

これをつかって現在日時をMySQLの日付書式で取得する処理を書いてみた。

-- 戻り値:文字列(ex. '2014-03-16 10:17:05')
to getCurrentDateString()
    set current_date to current date

    set val_year to year of current_date
    set val_month to month of current_date as number
    set val_day to day of current_date
    set val_time to time string of current_date
    set date_time_string to ""

    if val_month < 10 then
        set val_month to "0" & val_month as string
    end if

    if val_day < 10 then
        set val_day to "0" & val_day as string
    end if

    set date_time_string to val_year & "-" & val_month & "-" & val_day & " " & val_time as string
    return date_time_string
end getCurrentDateString
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away