<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Time on Cheat Sheet</title><link>/tags/time/</link><description>Recent content in Time on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/time/index.xml" rel="self" type="application/rss+xml"/><item><title>time</title><link>/programming/go/std/time/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/go/std/time/</guid><description>&lt;h1 id="time"&gt;time&lt;a class="anchor" href="#time"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;h2 id="timeduration"&gt;&lt;code&gt;time.Duration&lt;/code&gt;&lt;a class="anchor" href="#timeduration"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;time.ParseDuration(s string) (Duration, error)&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;Parses a duration string into a &lt;code&gt;time.Duration&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="timetime"&gt;&lt;code&gt;time.Time&lt;/code&gt;&lt;a class="anchor" href="#timetime"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Represents a specific moment in time (time stamp) and includes time zone information.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Comparison:&lt;/strong&gt; Do not use &lt;code&gt;==&lt;/code&gt; to check if two &lt;code&gt;time.Time&lt;/code&gt; instances refer to the same moment. Instead, use the &lt;code&gt;Equal&lt;/code&gt; method, which correctly handles time zones.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="parsing-and-formatting"&gt;Parsing and Formatting&lt;a class="anchor" href="#parsing-and-formatting"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;time.Parse(layout, value string) (Time, error)&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;Parses a formatted string into a &lt;code&gt;Time&lt;/code&gt; value.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;layout&lt;/code&gt; defines the format using the reference time: &lt;code&gt;Jan 2 15:04:05 2006 MST&lt;/code&gt; (&lt;code&gt;&amp;quot;01/02 03:04:05PM '06 -0700&amp;quot;&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;func (t Time) Format(layout string) string&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;Returns a string representation of the time formatted according to &lt;code&gt;layout&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="timers-and-tickers"&gt;Timers and Tickers&lt;a class="anchor" href="#timers-and-tickers"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Go provides two distinct primitives for scheduling time-based events over channels: &lt;strong&gt;Timers&lt;/strong&gt; (one-shot countdowns) and &lt;strong&gt;Tickers&lt;/strong&gt; (repeating metronomes). Both expose a receive-only channel of type &lt;code&gt;&amp;lt;-chan time.Time&lt;/code&gt; that delivers the exact &lt;code&gt;time.Time&lt;/code&gt; timestamp when fired, and both share the same underlying Go runtime timer engine (&lt;code&gt;period = 0&lt;/code&gt; for &lt;code&gt;Timer&lt;/code&gt; vs &lt;code&gt;period = d&lt;/code&gt; for &lt;code&gt;Ticker&lt;/code&gt;).&lt;/p&gt;</description></item></channel></rss>