<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Преобразовать дату и время в миллисекунды]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12335&amp;type=atom" />
	<updated>2017-01-20T15:39:55Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12335</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111291#p111291" />
			<content type="html"><![CDATA[<p>Да. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Но я бы их всё равно писал, всё-таки значащие цифры, так понятнее.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-20T15:39:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111291#p111291</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111290#p111290" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>time -= 19700101, s</p></blockquote></div><p>0101 в конце не нужны:<br /></p><div class="codebox"><pre><code>date = 22.08.2016
time = 17:00
RegExMatch(date time, &quot;(..)\.(..)\.(....)(..):(..)&quot;, match)
TimeStamp := match3 match2 match1 match4 match5
TimeStamp -= 1970, s
MsgBox, % TimeStamp * 1000</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-20T15:36:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111290#p111290</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111289#p111289" />
			<content type="html"><![CDATA[<p>Нули в конце не нужны:<br /></p><div class="codebox"><pre><code>time = 2016082217
time -= 19700101, s
msgbox % time*1000</code></pre></div><p>Или, если с изначальными переменными:<br /></p><div class="codebox"><pre><code>date = 22.08.2016
time = 17:00
RegExMatch(date, &quot;(..)\.(..)\.(....)&quot;, match)
RegExMatch(time, &quot;(..):(..)&quot;, found)
TimeStamp := match3 . match2 . match1 . found1 . found2
TimeStamp -= 19700101, S
MsgBox, % TimeStamp * 1000</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-20T13:08:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111289#p111289</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111287#p111287" />
			<content type="html"><![CDATA[<p>А в чем сложность-то?<br /></p><div class="codebox"><pre><code>time = 20160822170000
time -= 19700101000000,seconds
msgbox % time*1000</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-01-20T12:59:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111287#p111287</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111286#p111286" />
			<content type="html"><![CDATA[<p>Не совсем понял. Тебе нужно системное время в миллисекунды отформатировать? Но как ты это представляешь? Например сейчас 12:00, ты запускаешь скрипт, а он выдает тебе 1200000000 миллисекунд, так (нолики в миллисекундах рандомные, потом точно сделаю)? Или тебе нужно отформатировать время относительно какой-то даты. Например: сколько миллисекунд прошло с 20:00 вчерашнего дня?</p>]]></content>
			<author>
				<name><![CDATA[belyankin12]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34408</uri>
			</author>
			<updated>2017-01-20T12:59:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111286#p111286</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111285#p111285" />
			<content type="html"><![CDATA[<p>Привет.<br />Возможно <a href="https://autohotkey.com/board/topic/2486-code-to-convert-fromto-unix-timestamp/">это</a> сгодится.<br />Можно записать как:<br /></p><div class="codebox"><pre><code>
UnixTime() {
;###############Convert YYYYMMDDHHMISS into Unix timestamp#############

	time_orig=%A_NOW%

	StringLeft, now_year, time_orig, 4
	StringMid, now_month, time_orig, 5, 2
	StringMid, now_day, time_orig, 7, 2
	StringMid, now_hour, time_orig, 9, 2
	StringMid, now_min, time_orig, 11, 2
	StringRight, now_sec, time_orig, 2

	;Get year seconds
	year_sec := 31536000*(now_year - 1970)

	;Determine how many leap days
	leap_days := (now_year - 1972)/4 + 1
	Transform, leap_days, Floor, %leap_days%

	;Determine if date is in a leap year, and if the leap day has been yet
	this_leap := now_year/4
	Transform, this_leap_round, Floor, %this_leap%
	If (this_leap = this_leap_round)
	  {
	  If now_month &lt;= 2
		leap_days--   ;subtracts 1 because this year&#039;s leap day hasn&#039;t been yet
	  }
	leap_sec := leap_days*86400

	;Determine fully completed months
	If now_month = 01
	  month_sec = 0
	If now_month = 02
	  month_sec = 2678400
	If now_month = 03
	  month_sec = 5097600
	If now_month = 04
	  month_sec = 7776000
	If now_month = 05
	  month_sec = 10368000
	If now_month = 06
	  month_sec = 13046400
	If now_month = 07
	  month_sec = 15638400
	If now_month = 08
	  month_sec = 18316800
	If now_month = 09
	  month_sec = 20995200
	If now_month = 10
	  month_sec = 23587200
	If now_month = 11
	  month_sec = 26265600
	If now_month = 12
	  month_sec = 28857600

	  
	;Determine fully completed days
	day_sec := (now_day - 1)*86400

	;Determine fully completed hours
	hour_sec := now_hour*3600 ;don&#039;t subtract 1 because it starts at 0

	;Determine fully completed minutes
	min_sec := now_min*60

	;Calculate total seconds
	date_sec := year_sec + month_sec + day_sec + leap_sec + hour_sec + min_sec + now_sec
	return date_sec
}

</code></pre></div><p>Тогда вызов:<br /></p><div class="codebox"><pre><code>
totalSec:=UnixTime()
</code></pre></div><p>Передаст количество прошедших секунд с 1 января 1970 года. Умножаешь результат на 1000 и получаешь миллисекунды.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2017-01-20T12:56:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111285#p111285</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111284#p111284" />
			<content type="html"><![CDATA[<p>Мне нужно это для последующей обработки даты в Java, класс Date который хранит время в миллисекундах начиная с 1 января 1970 года. Вот это период и нужен.</p>]]></content>
			<author>
				<name><![CDATA[Zohann]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26234</uri>
			</author>
			<updated>2017-01-20T12:46:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111284#p111284</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111283#p111283" />
			<content type="html"><![CDATA[<p>В милисекунды можно форматировать только период времени.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-01-20T12:36:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111283#p111283</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Преобразовать дату и время в миллисекунды]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111282#p111282" />
			<content type="html"><![CDATA[<p>Приветствую!<br />Есть дата и время, как форматировать их в миллисекунды?<br /></p><div class="codebox"><pre><code>date = 22.08.2016 
time = 17:00</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Zohann]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26234</uri>
			</author>
			<updated>2017-01-20T12:33:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111282#p111282</id>
		</entry>
</feed>
