<?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: Ibrahim Ibrahim</title>
    <description>The latest articles on DEV Community by Ibrahim Ibrahim (@iaboelsuod).</description>
    <link>https://dev.to/iaboelsuod</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%2F46738%2F6a83741a-f879-45a4-ad98-c907a027e6c0.jpg</url>
      <title>DEV Community: Ibrahim Ibrahim</title>
      <link>https://dev.to/iaboelsuod</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iaboelsuod"/>
    <language>en</language>
    <item>
      <title>Angular Hidden Time Pipe</title>
      <dc:creator>Ibrahim Ibrahim</dc:creator>
      <pubDate>Tue, 18 Feb 2020 09:02:23 +0000</pubDate>
      <link>https://dev.to/iaboelsuod/angular-hidden-time-pipe-i71</link>
      <guid>https://dev.to/iaboelsuod/angular-hidden-time-pipe-i71</guid>
      <description>&lt;p&gt;I was integrating an API when I found myself faced with this data format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dateRange: {
  date: '2020/02/02',
  fromTime: '10:00',
  toTime: '13:30',
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It was required to display the date in the following format:&lt;br&gt;
&lt;em&gt;2 Feb 2020 [10:00 AM- 01:30 PM]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now you might have noticed the time field is in 24 hours format while we need 12 hours format.&lt;br&gt;
A time pipe would be perfect for this, except seemingly Angular doesn't include one!&lt;/p&gt;

&lt;p&gt;I was about to try my luck with some 3rd party pipe but I wasn't comfortable with including a dependency for such a simple pipe. Should I build it myself?&lt;/p&gt;

&lt;p&gt;Then I had an idea, maybe I can construct a date object from the time portion? I don't care what day/month it is; I will be just displaying the time portion anyway right?&lt;br&gt;
Even better... what if:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{dateRange.date + ' ' + dateRange.toTime | date: 'hh:mm aa'}}
&amp;lt;!-- Output --&amp;gt;
&amp;lt;!-- 01:30 PM --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{'01/01/1900 ' + dateRange.toTime | date: 'hh:mm aa'}}
&amp;lt;!-- Output --&amp;gt;
&amp;lt;!-- 01:30 PM --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SUCCESS!!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;br&gt;
Yeah, we just use the date pipe but append a &lt;code&gt;day/month/year&lt;/code&gt; string ahead of the time portion.&lt;/p&gt;

&lt;p&gt;Disclaimer:&lt;br&gt;
This is my first technical "artical" -if we can call it that. Wanted to start simple and I didn't counter any mention of this "trick" online. &lt;br&gt;
Any feedback is appreciated ^^.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>html</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
