<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://zichen.u8cat.pl/feed.xml" rel="self" type="application/atom+xml" /><link href="https://zichen.u8cat.pl/" rel="alternate" type="text/html" /><updated>2026-07-11T10:20:58+00:00</updated><id>https://zichen.u8cat.pl/feed.xml</id><title type="html">Zichen Zhang</title><subtitle>CS PhD student</subtitle><author><name>Zichen Zhang</name><email>$FIRST$LAST@nyu.edu</email></author><entry><title type="html">Setting Timestamp in Second-Level Precision in Google Photo</title><link href="https://zichen.u8cat.pl/posts/2025/07/google-photo/" rel="alternate" type="text/html" title="Setting Timestamp in Second-Level Precision in Google Photo" /><published>2025-07-11T00:00:00+00:00</published><updated>2025-07-11T00:00:00+00:00</updated><id>https://zichen.u8cat.pl/posts/2025/07/google-photo</id><content type="html" xml:base="https://zichen.u8cat.pl/posts/2025/07/google-photo/"><![CDATA[<p>Users of <a href="https://www.google.com/photos/about/">Google Photo</a> should be aware that although the photo information interface only displays a time in minutes, photos taken within one minute are <em>usually</em> sorted correctly in chronological order. While some people might think they are sorted by filename or upload order, the truth is that they are still sorted by time but using an internal millisecond timestamp.</p>

<p>This internal timestamp can be problematic when users manually specify the date &amp; time of a photo using Google Photo interface because this will truncate the timestamp to minute<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>, resulting in a problem known as wrong order of photos with “the same” timestamp<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup><sup id="fnref:3" role="doc-noteref"><a href="#fn:3" class="footnote" rel="footnote">3</a></sup>. Despite reported by many users, to the best of my knowledge, no solution or workaround has been proposed by users, nor has Google revealed any plan to fix it. This article studies the mechanism of the internal timestamp and then proposes a method to set timestamps with precision up to the second in Google Photo.</p>

<h1 id="mechanism-of-the-internal-timestamp">Mechanism of the Internal Timestamp</h1>

<p>Though the internal timestamp is crucial in photo sorting, the mechanism of it is very subtle and inconsistent. Because the algorithm used by Google Photo is proprietary, this section only describes a possible mechanism based on my experiments.</p>

<h2 id="creation">Creation</h2>

<p>The internal timestamp is created when a photo is uploaded, based on the EXIF data of the picture file, or the modification time recorded in the filesystem if the EXIF data is missing. There are many EXIF fields related to time, such as <code class="language-plaintext highlighter-rouge">CreateDate</code>, <code class="language-plaintext highlighter-rouge">SubSecCreateDate</code> and <code class="language-plaintext highlighter-rouge">SubSecTime</code>, and each of them could have <code class="language-plaintext highlighter-rouge">Original</code> and <code class="language-plaintext highlighter-rouge">Digitized</code> variants. It is not clean which field(s) does Google Photo look for, but eventually, it will obtain a millisecond <code class="language-plaintext highlighter-rouge">timestamp</code> and a <code class="language-plaintext highlighter-rouge">timezone</code>. For instance, if the EXIF has field <code class="language-plaintext highlighter-rouge">SubSecDateTimeOriginal</code> equaling to <code class="language-plaintext highlighter-rouge">2025:07:10 20:29:22.381+00:00</code>, then the <code class="language-plaintext highlighter-rouge">timestamp</code> will be <code class="language-plaintext highlighter-rouge">2025-07-10T20:29:22.381</code> and the <code class="language-plaintext highlighter-rouge">timezone</code> will be <code class="language-plaintext highlighter-rouge">+00:00</code>.</p>

<p>Because all photos are not perfectly timestamped, Google Photo has to handle missing data. The <code class="language-plaintext highlighter-rouge">timestamp</code> part is easy: the millisecond part defaults to <code class="language-plaintext highlighter-rouge">000</code> and it is thus always possible to obtain a timestamp. However, the <code class="language-plaintext highlighter-rouge">timezone</code> part is far more complex: when relevant EXIF fields are missing, Google Photo will infer it from GPS data and if GPS data is also missing, Google Photo will use the timezone of the uploader’s IP address. Now we have three sources of timezone: (A) timezone recorded in <code class="language-plaintext highlighter-rouge">SubSecCreateDate</code> or <code class="language-plaintext highlighter-rouge">SubSecDateTimeOriginal</code> in the EXIF data; (B) the GPS coordinate in the EXIF data; (C) the IP address of the uploader. It is actually very common for these three sources to be inconsistent. For example, using UTC worldwide may result in conflict between sources (A) and (B); uploading photos after returning from an international trip may result in conflict between sources (A) and (C). In the presence of a conflict, source (B) has the highest priority, followed by source (A), and source (C) is least significant.</p>

<p>The story doesn’t end after Google Photo has determined the <code class="language-plaintext highlighter-rouge">timestamp</code> and the <code class="language-plaintext highlighter-rouge">timezone</code> fields. Recall that when timezone sources (A) and (B) are inconsistent, Google Photo will use source (B) as the eventual timezone source, but will it adjust <code class="language-plaintext highlighter-rouge">timestamp</code> based on the new timezone? The answer is (surprisingly) <em>maybe</em>, i.e., sometimes will and sometimes won’t. Again, using the example of the photo taken on <code class="language-plaintext highlighter-rouge">2025:07:10 20:29:22.381+00:00</code>, now suppose this photo’s EXIF indicates that it was taken in New York whose timezone in <code class="language-plaintext highlighter-rouge">-04:00</code>. Because source (B) has higher priority, the eventual <code class="language-plaintext highlighter-rouge">timezone</code> will be <code class="language-plaintext highlighter-rouge">-04:00</code>, but the <code class="language-plaintext highlighter-rouge">timestamp</code> may be either (1) converted to <code class="language-plaintext highlighter-rouge">2025-07-10T16:29:22.381</code> (which is expected), or (2) persevered as <code class="language-plaintext highlighter-rouge">2025-07-10T20:29:22.381</code> (which is incorrect). In fact, both behavior (1) and behavior (2) happen frequently to me that I have to manually edit the “date &amp; time” of approximately one third of my photos.</p>

<p>Once created, <code class="language-plaintext highlighter-rouge">timezone</code> and <code class="language-plaintext highlighter-rouge">timezone</code> will be stored separately as internal meta data <em>independent</em> of the picture file.</p>

<h2 id="sorting-photos">Sorting Photos</h2>

<p>Besides being truncated to minute and then displayed to the user, the <em>only</em> function of the internal timestamp is to sort photos in chronological order. Unfortunately, Google did not even implement this only function correctly. When there are multiple photos in different timezone, the expected behavior is sorting them in the absolute time rather than local time, e.g., <code class="language-plaintext highlighter-rouge">2025-07-10T20:00:00+00:00</code> is prior to (happens earlier) <code class="language-plaintext highlighter-rouge">2025-07-10T17:00:00-04:00</code> despite a greater value in local time. The web version of Google Photo behaves as expected, but its mobile app mistakenly sorts photos in local time. Sorting in local time means photos taken on a cross Pacific flight or in a town near timezone border will be missed up.</p>

<h2 id="editing">Editing</h2>

<p>The non-deterministic behavior due to the conflict between sources (A) and (B) is my major motivation to manually edit the timestamps of my photos. For other people, the most common motivation is that source (C) is often incorrect<sup id="fnref:4" role="doc-noteref"><a href="#fn:4" class="footnote" rel="footnote">4</a></sup><sup id="fnref:5" role="doc-noteref"><a href="#fn:5" class="footnote" rel="footnote">5</a></sup>.</p>

<p>When editing the date &amp; time of a photo, the interface only shows the time in minutes, and after editing, the second and millisecond part of the timestamp will be <em>reset to zero</em>. As a result, if there are two photos taken within one minutes, one with the automatically created internal timestamp and the other with manually edited timestamp, the second one will be prior to the first one regarding of their true taken time (unless in an extremely rare case where the first photo was taken exactly on the zeroth millisecond of that minute).</p>

<p>Google Photo also allows editing in batch. When editing the date &amp; time of multiple photos at the same time, the user could choose to specify the timestamp of the first photo (the photo taken the earliest) and preserve the relative time between photos. In this case, the timestamp of the first photo will be truncated to minute, but the timestamp difference between the first photo and the remaining photos will be preserved at second-level (I initially thought it would be millisecond-level, but further experiments show that it is only second-level, and the timestamp of the remaining photos will be truncated to second). As a result, if the first photo has timestamp <code class="language-plaintext highlighter-rouge">13:01:32</code>, the timestamp of all photos will be subtracted by 32s. Consequently, a photo take at <code class="language-plaintext highlighter-rouge">17:01:10</code> will now have timestamp <code class="language-plaintext highlighter-rouge">17:00:38</code>. This subtraction is sufficient to cause the timestamp of a photo has a wrong minute field.</p>

<p>Editing the internal timestamp will not change the picture file.</p>

<h1 id="precisely-editing-timestamps">Precisely Editing Timestamps</h1>

<p>Although the behavior of truncating during editing is annoying, it is actually possible to make use of the feature to precisely set the timestamp of a photo.</p>

<h2 id="correcting-timezone">Correcting Timezone</h2>

<p>Before discussing how to specify the timestamp of a photo, let’s first study a more common scenario—correcting the wrong timezone inferred during uploading<sup id="fnref:1:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>. Although we could easily change the timestamp and timezone of photos in batch, doing this naively will result in the subtraction of timestamp.</p>

<p>Observing that the subtraction phenomenon changes the second field of the first photo to zero, if the field is already zero, then this phenomenon will not happen. We don’t have to scarify any photos to make the first photo have zero second field; instead, we can upload a dummy picture, edit its timestamp to be prior to the first photo, and use the dummy photo to change the timestamps of useful photos in batch. Summarizing in pseudocode (because there is no Google Photo API to manage existing photos, it is very tricky to write a machine-executable script), the procedure is:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>let S = the set of photos to edit in batch
create dummy.jpg (by using painting software or taking a photo)
upload dummy.jpg
let t = min(S.timestamp)
edit timestamp of dummy.jpg to t - 1min (this truncates dummy's timestamp and ensures dummy is the first photo)
select (S ∪ dummy.jpg)
edit timestamp (including timezone) of selected photos to the desired value
delete dummy.jpg
</code></pre></div></div>

<h2 id="setting-timestamp">Setting Timestamp</h2>

<p>We can also precisely specify the timestamp (up to the second) using the dummy picture technique, but this time, we need to edit the EXIF data of the dummy picture (a good cross-platform tool is <a href="https://exiftool.org/">ExifTool</a>).</p>

<p>The process consists of two phases: setting the timestamp to a value greater than the target value, and subtracting the timestamp to the exact value. Suppose we want to set the timestamp of photo.jpg to <code class="language-plaintext highlighter-rouge">2025-07-10T20:29:22</code>. We first set it to 2025-07-10 20:30, the approximation of the target timestamp by rounding towards infinity. Now, we need to subtract the timestamp by 38s. This requires uploading a dummy picture with <code class="language-plaintext highlighter-rouge">SubSecDateTimeOriginal</code>=<code class="language-plaintext highlighter-rouge">2025-07-10T20:29:38.000+00:00</code> (timezone is added to prevent using source (C)). Using the <code class="language-plaintext highlighter-rouge">convert</code> command from <a href="http://www.imagemagick.org/">ImageMagick</a> and the ExifTool, this picture can be created by:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>convert <span class="nt">-size</span> 128x128 xc:red dummy.jpg
exiftool <span class="nt">-SubSecDateTimeOriginal</span><span class="o">=</span><span class="s2">"2025-07-10T20:29:38.000+00:00"</span> dummy.jpg
</code></pre></div></div>

<p>The final step is selecting dummy.jpg and photo.jpg, and change the data &amp; time of selected photos to 2025-07-10 20:29.</p>

<p>Due to the behavior of batch editing, this method can only set the timestamp to the zeroth millisecond of a second, i.e., the actual timestamp of photo.jpg will become <code class="language-plaintext highlighter-rouge">2025-07-10T20:29:22.000</code>. To verify this claim, we can upload two photos with timestamps <code class="language-plaintext highlighter-rouge">2025-07-10T20:29:21.999</code> and <code class="language-plaintext highlighter-rouge">2025-07-10T20:29:21.001</code>, respectively, and photo.jpg should be sorted between the two photos.</p>

<h3 id="generating-dummyjpg">Generating dummy.jpg</h3>

<p>Since manually create dummy.jpg described above is tedious, I wrote a script to automate this process.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>

<span class="c"># Usage: ./dummy.sh &lt;date&gt; &lt;time&gt;</span>
<span class="c"># Example: ./dummy.sh 2024-07-10 20:29:22</span>

<span class="nv">DATE</span><span class="o">=</span><span class="nv">$1</span>
<span class="nv">FULL_TIME</span><span class="o">=</span><span class="nv">$2</span>
<span class="nv">TIME</span><span class="o">=</span><span class="k">${</span><span class="nv">FULL_TIME</span>:0:5<span class="k">}</span>
<span class="nv">SECOND</span><span class="o">=</span><span class="k">${</span><span class="nv">FULL_TIME</span>:6:2<span class="k">}</span>
<span class="k">if</span> <span class="o">[[</span> <span class="k">${</span><span class="nv">SECOND</span>:0:1<span class="k">}</span> <span class="nt">-eq</span> <span class="s1">'0'</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
    </span><span class="nv">OFFSET</span><span class="o">=</span><span class="k">$((</span> <span class="m">60</span> <span class="o">-</span> <span class="k">${</span><span class="nv">SECOND</span>:1:1<span class="k">}</span> <span class="k">))</span>
<span class="k">else
    </span><span class="nv">OFFSET</span><span class="o">=</span><span class="k">$((</span> <span class="m">60</span> <span class="o">-</span> <span class="nv">$SECOND</span> <span class="k">))</span>
<span class="k">fi

</span><span class="nv">FILE</span><span class="o">=</span><span class="k">${</span><span class="nv">DATE</span><span class="k">}</span>T<span class="nv">$FULL_TIME</span>.jpg
<span class="nv">TIMESTAMP</span><span class="o">=</span><span class="s2">"</span><span class="si">$(</span><span class="nb">echo</span> <span class="nv">$DATE</span> | <span class="nb">sed </span>s/-/:/g<span class="si">)</span><span class="s2"> </span><span class="nv">$TIME</span><span class="s2">:</span><span class="nv">$OFFSET</span><span class="s2">.000+00:00"</span>

convert <span class="nt">-background</span> white <span class="nt">-fill</span> black <span class="nt">-pointsize</span> 128 label:<span class="s2">"</span><span class="nv">$DATE</span><span class="se">\n</span><span class="nv">$FULL_TIME</span><span class="s2">"</span> <span class="nv">$FILE</span>

exiftool <span class="nt">-SubSecDateTimeOriginal</span><span class="o">=</span><span class="s2">"</span><span class="nv">$TIMESTAMP</span><span class="s2">"</span> <span class="nv">$FILE</span> <span class="nt">-overwrite_original</span>
</code></pre></div></div>

<p>To use the script, the user specifies the target timestamp of the useful picture, and the script will calculate the timestamp of the dummy picture and generate a picture containing the text of the target timestamp.</p>

<h1 id="conclusion-and-limitation">Conclusion and Limitation</h1>

<p>I have proposed a method to set the timestamp of a photo in Google Photo to second-level precision, but this method will truncate the millisecond part of the timestamp to 0. This method is good enough for most daily use but can still miss up photos taken within one second.</p>

<h1 id="references">References</h1>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>Yang-z. The seconds value of timestamp get lost after adjusting the time of photos or videos on the web. 2018. https://support.google.com/photos/thread/660932/the-seconds-value-of-timestamp-get-lost-after-adjusting-the-time-of-photos-or-videos-on-the-web?hl=en Accessed: 2025-07-13 <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a> <a href="#fnref:1:1" class="reversefootnote" role="doc-backlink">&#8617;<sup>2</sup></a></p>
    </li>
    <li id="fn:2" role="doc-endnote">
      <p>Adam A. Change the order of photos with the same timestamp. 2019. https://support.google.com/photos/thread/1032721/change-the-order-of-photos-with-the-same-timestamp?hl=en Accessed: 2025-07-10 <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:3" role="doc-endnote">
      <p>Martijn Groothuis. Google photos wrong order for sequence of photos. 2019. https://support.google.com/photos/thread/10211279?hl=en Accessed: 2025-07-10 <a href="#fnref:3" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:4" role="doc-endnote">
      <p>nontavit. Google Photos sorting and time zone issue. 2017. https://medium.com/@nontavit/google-photos-and-time-zone-issue-b2e2d20645b0 Accessed: 2025-07-10 <a href="#fnref:4" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:5" role="doc-endnote">
      <p>-SpaghettiCat-. Google Photos Not Sorting In Correct Chronological Order. 2021. https://www.reddit.com/r/google/comments/r3mets/google_photos_not_sorting_in_correct/ Accessed: 2025-07-10 <a href="#fnref:5" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Zichen Zhang</name><email>$FIRST$LAST@nyu.edu</email></author><category term="tool" /><category term="tutorial" /><summary type="html"><![CDATA[Users of Google Photo should be aware that although the photo information interface only displays a time in minutes, photos taken within one minute are usually sorted correctly in chronological order. While some people might think they are sorted by filename or upload order, the truth is that they are still sorted by time but using an internal millisecond timestamp.]]></summary></entry></feed>