<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Replace Unix timestamp]]></title><description><![CDATA[<p dir="auto">How can a 13 digit unix timestamp be replaced with a readable time with Find and Replace?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/25308/replace-unix-timestamp</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 11:20:29 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/25308.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Jan 2024 16:46:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace Unix timestamp on Mon, 08 Jan 2024 10:52:25 GMT]]></title><description><![CDATA[<p dir="auto">@Dr-N ,<a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> ,<a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a><br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/91717">Replace Unix timestamp</a>:</p>
<blockquote>
<p dir="auto">I think that your result 2024-01-04 19:39:53 exceeds the right answer of one hour !</p>
</blockquote>
<p dir="auto">Thanks for pointing this out!</p>
<p dir="auto">Indeed, in my example, my local time zone has been automatically included into the calculation.<br />
In case it should be UTC ( which is one hour west of my location) this should be indicated by a <strong>“!”</strong> in the format string.<br />
So the Replace  of my (two) Cature Group example should look like this .</p>
<p dir="auto">Previous example with local time zone (Thu Jan  4 <strong>19:39:53</strong> 2024):<br />
<code>set(CAP1..os.date("%c", math.floor(CAP2/1000)))</code></p>
<p dir="auto">New example with UTC time (Thu Jan  4 <strong>18:39:53</strong> 2024):<br />
<strong><code>set(CAP1..os.date("!%c", math.floor(CAP2/1000)))</code></strong></p>
<p dir="auto">Details are described here:<br />
<a href="https://www.lua.org/manual/5.4/manual.html#pdf-os.date" rel="nofollow ugc">Lua os.date description</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/91844</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91844</guid><dc:creator><![CDATA[Thomas Knoefel]]></dc:creator><pubDate>Mon, 08 Jan 2024 10:52:25 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Mon, 08 Jan 2024 11:25:42 GMT]]></title><description><![CDATA[<p dir="auto">@Dr-N said in <a href="/post/91718">Replace Unix timestamp</a>:</p>
<blockquote>
<p dir="auto">Replacing the 13 digit unix timestamp showed this error, see picture.</p>
</blockquote>
<p dir="auto">My example, was designed for <strong>two</strong> capture groups. In regex, capture groups are enclosed in parentheses. In MultiReplace, they are captured in the numbered CAP variables.<br />
As you have only one capture group in your Find, which holds the timestamp, the second capture group (CAP2) is empty, as indicated by nil.</p>
<p dir="auto">My previous example:<br />
String to search for: <strong>time=1704393593000</strong><br />
Find what: <strong>(time=)(\d{13})</strong><br />
CAP1 = <strong>‘time=’</strong><br />
CAP2 = <strong>13 digit timestamp</strong><br />
Replace with: <code>set(CAP1..os.date(“%c”, math.floor(CAP2/1000)))</code></p>
<p dir="auto">you probably changed it to that:<br />
String to search for: <strong>1704393593000</strong><br />
Find what: <strong>(\d{13})</strong><br />
<strong>CAP1 = 13 digit timestamp</strong><br />
for that the replace phrase should look like this<br />
Replace with: <strong><code>set(os.date("%c", math.floor(CAP1/1000)))</code></strong></p>
<p dir="auto">You can find more details here:<br />
<a href="https://github.com/daddel80/notepadpp-multireplace?tab=readme-ov-file#option-use-variables" rel="nofollow ugc">MultiReplace “Use Variables” manual</a></p>
<p dir="auto">I hope this helps …</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91843</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91843</guid><dc:creator><![CDATA[Thomas Knoefel]]></dc:creator><pubDate>Mon, 08 Jan 2024 11:25:42 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Fri, 05 Jan 2024 14:58:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thomas-knoefel" aria-label="Profile: Thomas-Knoefel">@<bdi>Thomas-Knoefel</bdi></a> said in <a href="/post/91696">Replace Unix timestamp</a>:</p>
<blockquote>
<p dir="auto">set(CAP1…os.date(“%c”, math.floor(CAP2/1000)))</p>
</blockquote>
<p dir="auto">Thanks Thomas…</p>
<p dir="auto">Replacing the 13 digit unix timestamp showed this error, see picture.<br />
<img src="/assets/uploads/files/1704466668761-2024-01-05_215327.jpg" alt="2024-01-05_215327.jpg" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/91718</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91718</guid><dc:creator><![CDATA[Dr. N]]></dc:creator><pubDate>Fri, 05 Jan 2024 14:58:19 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Fri, 05 Jan 2024 14:54:33 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @dr-n, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/rdipardo" aria-label="Profile: rdipardo">@<bdi>rdipardo</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: coises">@<bdi>coises</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/mark-olson" aria-label="Profile: mark-olson">@<bdi>mark-olson</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/thomas-knoefel" aria-label="Profile: thomas-knoefel">@<bdi>thomas-knoefel</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thomas-knoefel" aria-label="Profile: thomas-knoefel">@<bdi>thomas-knoefel</bdi></a>, I think that your result <strong><code>2024-01-04 19:39:53</code></strong> exceeds the right answer of <strong>one</strong> hour !</p>
<p dir="auto">Indeed, for the <strong>Unix datestamp</strong> <strong><code>1704393593</code></strong>, expressed in <strong>seconds</strong>, the <strong>correct</strong> result is <strong><code>2024-01-04 18:39:53</code></strong></p>
<p dir="auto">Note that it is the <a class="plugin-mentions-user plugin-mentions-a" href="/user/rdipardo" aria-label="Profile: rdipardo">@<bdi>rdipardo</bdi></a> result !</p>
<p dir="auto">You can verify my assumption with the 3 <strong>on-line</strong> converters, below :</p>
<p dir="auto"><a href="https://www.unixtimestamp.com/" rel="nofollow ugc">https://www.unixtimestamp.com/</a></p>
<p dir="auto"><a href="https://unixtime.org/" rel="nofollow ugc">https://unixtime.org/</a></p>
<p dir="auto"><a href="https://www.epochconverter.com/" rel="nofollow ugc">https://www.epochconverter.com/</a></p>
<hr />
<p dir="auto"><strong>Remark</strong> :</p>
<ul>
<li>When using the <strong>first two</strong> sites, if you do the <strong>reverse</strong> operation ( <strong>Date</strong> to <strong>Epoch timestamp</strong> ), you <strong>must</strong> use the time indicated in the row <strong><code>Your time zone</code></strong> in order to get the <strong>correct</strong> number <strong><code>1704393593</code></strong></li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91717</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91717</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 05 Jan 2024 14:54:33 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Fri, 05 Jan 2024 00:51:42 GMT]]></title><description><![CDATA[<p dir="auto">@Dr-N<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a>, said in <a href="/post/91692">Replace Unix timestamp</a>:</p>
<blockquote>
<p dir="auto">I believe you can do this with the MultiReplace  plugin.</p>
</blockquote>
<p dir="auto">I did converted the timestamp into a readable format with <a href="https://github.com/daddel80/notepadpp-multireplace?tab=readme-ov-file#multireplace-for-notepad" rel="nofollow ugc">MultiReplace</a> close to <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> solution:</p>
<p dir="auto">Time to be converted: <strong>time=1704393593000</strong><br />
Find what: <code>(time=)(\d{13})</code><br />
Replace with: <code>set(CAP1..os.date("%c", math.floor(CAP2/1000)))</code><br />
Result is: <strong>time=Thu Jan  4 19:39:53 2024</strong></p>
<p dir="auto">Time to be converted: <em><strong>time=1704393593</strong></em><br />
Find what: <code>(time=)(\d{10})</code><br />
Replace with: <code>set(CAP1..os.date("%Y-%m-%d %H:%M:%S", CAP2))</code><br />
Result is: <strong>time=2024-01-04 19:39:53</strong></p>
<p dir="auto">You have to enable the Options “<strong>Use Variables</strong>” and “<strong>Regex</strong>” in MultiReplace.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91696</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91696</guid><dc:creator><![CDATA[Thomas Knoefel]]></dc:creator><pubDate>Fri, 05 Jan 2024 00:51:42 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Fri, 05 Jan 2024 00:04:12 GMT]]></title><description><![CDATA[<p dir="auto">This PythonScript solution should work fine</p>
<pre><code class="language-py">'''
requires PythonScript: https://github.com/bruderstein/PythonScript/releases
docs: https://docs.python.org/3/library/datetime.html 
ref: https://community.notepad-plus-plus.org/topic/25308/replace-unix-timestamp/5
'''
# needed if using print() in Python 2
from __future__ import print_function
import datetime
from Npp import editor

THING_PRECEDING_TIMESTAMPS = '^time='
# see https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
#     for docs on this time format
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
PATTERN_TO_REPLACE = r'(%s)(\d{13})' % (THING_PRECEDING_TIMESTAMPS,)

def timestamp_str_to_date(timestamp_str, time_format=TIME_FORMAT):
    '''converts a 13-digit timestamp string into a
    date string in the desired format (default YYYY-MM-DD hh:mm:ss)
    '''
    timestamp = float(timestamp_str) / 1000
    dt = datetime.datetime.fromtimestamp(timestamp)
    # print(dt)
    return dt.strftime(time_format)


editor.rereplace(PATTERN_TO_REPLACE,
    lambda m: m.group(1) + timestamp_str_to_date(m.group(2)))
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/91695</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91695</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Fri, 05 Jan 2024 00:04:12 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Thu, 04 Jan 2024 23:00:37 GMT]]></title><description><![CDATA[<p dir="auto">@Dr-N said in <a href="/post/91678">Replace Unix timestamp</a>:</p>
<blockquote>
<p dir="auto">How can a 13 digit unix timestamp be replaced with a readable time with Find and Replace?</p>
</blockquote>
<p dir="auto">I believe you can do this with the <a href="https://github.com/daddel80/notepadpp-multireplace" rel="nofollow ugc">MultiReplace</a> plugin.</p>
<p dir="auto">This appeared to work when I tried it:</p>
<p dir="auto"><strong>Find what: <code>(time=)(\d{13})</code></strong><br />
<strong>Replace with: <code>set(CAP1..os.date("%c",CAP2/1000+os.time({year=1970,month=1,day=1})))</code></strong></p>
<p dir="auto">but I’ll leave it to <a class="plugin-mentions-user plugin-mentions-a" href="/user/thomas-knoefel" aria-label="Profile: Thomas-Knoefel">@<bdi>Thomas-Knoefel</bdi></a>, the author of the plugin, to clarify the finer points, which I might have all mixed up. The plugin uses Lua expressions; I found the date and time functions described <a href="https://www.lua.org/manual/5.1/manual.html#5.8" rel="nofollow ugc">here</a>. It should be possible to format the date/time from the timestamp as desired using the first argument of os.date. The os.time function is there to adjust the epoch from Unix to Windows, and the division by 1000 is because Lua’s time/date functions work in seconds but Unix timestamps are in milliseconds.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91692</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91692</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Thu, 04 Jan 2024 23:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Thu, 04 Jan 2024 20:12:30 GMT]]></title><description><![CDATA[<p dir="auto"><strong>P.S.</strong><br />
I should have mentioned that — since <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5813#issue-459178818" rel="nofollow ugc">version 7.7</a> — reloaded files <em>cannot</em> be restored by <code>SCI_UNDO</code> (<code>CTRL+Z</code>, <code>Edit &gt; Undo</code>, etc.).</p>
<p dir="auto">@Dr-N, you would do better to wait till someone posts the obligatory Python script.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91690</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91690</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Thu, 04 Jan 2024 20:12:30 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Thu, 04 Jan 2024 20:05:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/91679">Replace Unix timestamp</a>:</p>
<blockquote>
<p dir="auto">Notepad++ search and replace doesn’t do math.</p>
</blockquote>
<p dir="auto">True. Fortunately any scripting language can, and every PC at least has PowerShell pre-installed. So you could save a script like this, then have N++ run it by pressing <code>F5</code> and filling in the box with:</p>
<pre><code>powershell %USERPROFILE%\epoch_to_date.ps1 $(CURRENT_WORD) $(FULL_CURRENT_PATH)
</code></pre>
<p dir="auto">where <code>$(FULL_CURRENT_PATH)</code> is the active file (must be saved to disk first, not <code>new #</code>), and <code>$(CURRENT_WORD)</code> is a Unix timestamp that’s under the caret:</p>
<pre><code class="language-ps"># %UserProfile%\epoch_to_date.ps1
&lt;#
.SYNOPSIS
    Coverts all occurrences of a Unix timestamp to a calendar date in a given file.
.PARAMETER UnixEpoch
    A Unix timestamp.
.PARAMETER OutFile
   Full path to the file to process.
.EXAMPLE
    PS C:\&gt; ./epoch_to_date.ps1 1704393593 C:\file.txt
#&gt;
param(
  [Int64]$UnixEpoch = 0L,
  [string]$OutFile
)
$WindowsTime=($UnixEpoch*10000000)+116444736000000000
$Date=[datetime]::FromFileTimeUtc($WindowsTime)

(Get-Content -Path $OutFile) -Replace $UnixEpoch.ToString(), $Date | Set-Content -Path $OutFile
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1704398648937-run-dialog.png" alt="run-dialog.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="/assets/uploads/files/1704398672334-run-dialog-after-execute.png" alt="run-dialog-after-execute.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="/assets/uploads/files/1704398687320-run-dialog-reloaded.png" alt="run-dialog-reloaded.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/91689</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91689</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Thu, 04 Jan 2024 20:05:58 GMT</pubDate></item><item><title><![CDATA[Reply to Replace Unix timestamp on Thu, 04 Jan 2024 17:31:24 GMT]]></title><description><![CDATA[<p dir="auto">@Dr-N ,</p>
<p dir="auto">It takes math to convert from unix timestamp to actual date and time.  Notepad++ search and replace doesn’t do math.</p>
<p dir="auto">See our FAQ for more, including plugins that might help you implement the math.</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/topic/23170/faq-can-i-do-a-mathematical-replacement">https://community.notepad-plus-plus.org/topic/23170/faq-can-i-do-a-mathematical-replacement</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/91679</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91679</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 04 Jan 2024 17:31:24 GMT</pubDate></item></channel></rss>