<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rinaldy</title>
    <description>The latest articles on DEV Community by Rinaldy (@rinaldycodes).</description>
    <link>https://dev.to/rinaldycodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F428500%2Ff6604f9a-06f8-4f36-8a82-3f3a73878538.png</url>
      <title>DEV Community: Rinaldy</title>
      <link>https://dev.to/rinaldycodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rinaldycodes"/>
    <language>en</language>
    <item>
      <title>How to check update react PWA app</title>
      <dc:creator>Rinaldy</dc:creator>
      <pubDate>Tue, 04 Apr 2023 13:21:31 +0000</pubDate>
      <link>https://dev.to/rinaldycodes/how-to-check-update-react-pwa-app-1792</link>
      <guid>https://dev.to/rinaldycodes/how-to-check-update-react-pwa-app-1792</guid>
      <description>&lt;p&gt;first, open your file serviceWorkerRegistration&lt;/p&gt;

&lt;p&gt;find this function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function registerValidSW(swUrl, config) {
  navigator.serviceWorker
    .register(swUrl)
    .then((registration) =&amp;gt; {

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and add this code below before registration.onupdatefound&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Check for updates at start.     
registration.update();     
// Check for updates every 5 min.      
setInterval(() =&amp;gt; {        
registration.update();        
console.log("Checked for update...");      
}, (1000 * 60) * 5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function registerValidSW(swUrl, config) {
  navigator.serviceWorker
    .register(swUrl)
    .then((registration) =&amp;gt; {

      // Check for updates at start.     
      registration.update();     
      // Check for updates every 5 min.      
      setInterval(() =&amp;gt; {        
        registration.update();        
        console.log("Checked for update...");      
      }, (1000 * 60) * 5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;second, and the last find  &lt;code&gt;if (config &amp;amp;&amp;amp; config.onUpdate) {&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;add alert for check if will be update&lt;br&gt;
alert("Update available! To update, close all windows and reopen");&lt;/p&gt;

&lt;p&gt;code will be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alert("Update available! To update, close all windows and reopen");

// Execute callback
if (config &amp;amp;&amp;amp; config.onUpdate) {
    config.onUpdate(registration);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;run command below:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;npm run build&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;run your app in server and to test its work or not,&lt;br&gt;
then edit some code &lt;/p&gt;

&lt;p&gt;run command &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;npm run build&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;then if has pop up alert show up&lt;/p&gt;

&lt;p&gt;congratulations your react PWA app has been checked update. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>pwa</category>
    </item>
    <item>
      <title>How to add hours to datetime using javascript</title>
      <dc:creator>Rinaldy</dc:creator>
      <pubDate>Tue, 04 Apr 2023 01:43:13 +0000</pubDate>
      <link>https://dev.to/rinaldycodes/how-to-add-hours-to-datetime-using-javascript-37of</link>
      <guid>https://dev.to/rinaldycodes/how-to-add-hours-to-datetime-using-javascript-37of</guid>
      <description>&lt;p&gt;`let date_string = "2023-03-19 07:55:03";&lt;br&gt;
let date_obj = new Date(date_string);&lt;/p&gt;

&lt;p&gt;date_obj.setHours(date_obj.getHours() + 7);&lt;/p&gt;

&lt;p&gt;let result = date_obj.toISOString().slice(0, 19).replace('T', ' ');&lt;/p&gt;

&lt;p&gt;console.log(result); // output: "2023-03-19 14:55:03"&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;Dengan cara tersebut mengubah tanggal data string menjadi objek Date, kemudian menambahkan 7 jam ke objek tersebut dengan menggunakan cara setHours(). Setelah itu, objek tanggal diubah kembali menjadi string dengan format yang sama seperti awalnya menggunakan metode toISOString() dan dihapus karakter "T" pada string hasilnya. Akhirnya, tanggal dan waktu yang dihasilkan ditampilkan pada konsol.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>test</title>
      <dc:creator>Rinaldy</dc:creator>
      <pubDate>Sat, 09 Apr 2022 13:44:14 +0000</pubDate>
      <link>https://dev.to/rinaldycodes/test-1b71</link>
      <guid>https://dev.to/rinaldycodes/test-1b71</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mzHFXU7L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2jl60ogchqr09a97fb9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mzHFXU7L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2jl60ogchqr09a97fb9.jpg" alt="Image description" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
