<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaScript Tricks | Student Projects</title>
	<atom:link href="https://studentprojects.in/category/software-development/javascript/javascript-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 10 Dec 2022 05:10:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>How to get yesterday&#8217;s date using JavaScript</title>
		<link>https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-get-yesterdays-date-using-javascript/</link>
					<comments>https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-get-yesterdays-date-using-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sat, 12 Mar 2022 17:52:58 +0000</pubDate>
				<category><![CDATA[JavaScript Tricks]]></category>
		<category><![CDATA[Date & Time]]></category>
		<category><![CDATA[Epoch time]]></category>
		<category><![CDATA[yesterday date]]></category>
		<category><![CDATA[js date]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=8690</guid>

					<description><![CDATA[<p>It is very simple! Find today&#8217;s date and subtract by one to get yesterday&#8217;s date. Here is the code: Output new Date() will fetch the current date and time. Pass it to setDate() function along with minus 1 to fetch today&#8217;s date. You can use setUTCHours() and pass 0 to set the time 0.</p>
<p>The post <a href="https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-get-yesterdays-date-using-javascript/">How to get yesterday’s date using JavaScript</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>It is very simple!</p>



<p>Find today&#8217;s date and subtract by one to get yesterday&#8217;s date. </p>



<p><strong>Here is the code:</strong></p>



<pre class="wp-block-code"><code lang="javascript" class="language-javascript">const today = new Date();
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);

console.log('Today\'s date &amp; time: ', today);
console.log('Yesterday\'s date &amp; time: ', yesterday);
console.log('');
console.log('Today\'s date: ', today.toDateString());
console.log('Yesterday\'s date: ', yesterday.toDateString());
console.log('');
console.log('Today\'s Epoch time: ', today.getTime());
console.log('Yesterday\'s Epoch time: ', yesterday.getTime());</code></pre>



<p><strong>Output</strong></p>



<pre class="wp-block-code"><code class="">Today's date &amp; time:  2022-03-12T17:45:29.734Z
Yesterday's date &amp; time:  2022-03-11T17:45:29.734Z

Today's date:  Sat Mar 12 2022
Yesterday's date:  Fri Mar 11 2022

Today's Epoch time:  1647107129734
Yesterday's Epoch time:  1647020729734</code></pre>



<p>new Date() will fetch the current date and time. Pass it to setDate() function along with minus 1 to fetch today&#8217;s date. You can use setUTCHours() and pass 0 to set the time 0.</p>



<pre class="wp-block-code"><code class="">today.setUTCHours(0, 0, 0, 0);</code></pre>



<pre class="wp-block-code"><code class="">Today's date &amp; time:  2022-03-12T00:00:00.000Z</code></pre><p>The post <a href="https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-get-yesterdays-date-using-javascript/">How to get yesterday’s date using JavaScript</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-get-yesterdays-date-using-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to convert a sentence to a Title case in JavaScript</title>
		<link>https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-convert-a-sentence-to-a-title-case-in-javascript/</link>
					<comments>https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-convert-a-sentence-to-a-title-case-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 10 Mar 2022 18:34:42 +0000</pubDate>
				<category><![CDATA[JavaScript Tricks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Title case]]></category>
		<category><![CDATA[Regular expression]]></category>
		<category><![CDATA[RegEx]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=8622</guid>

					<description><![CDATA[<p>Title case is any text, such as in a title or heading, where the first letter of words is capitalized. So we can achieve this by changing the first element of every word in a sentence to uppercase while leaving the other elements in lowercase. Output</p>
<p>The post <a href="https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-convert-a-sentence-to-a-title-case-in-javascript/">How to convert a sentence to a Title case in JavaScript</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Title case is any text, such as in a title or heading, where the first letter of words is capitalized. So we can achieve this by changing the first element of every word in a sentence to uppercase while leaving the other elements in lowercase.</p>



<pre class="wp-block-code"><code lang="javascript" class="language-javascript">function toTitleCase(string) {
  if (string === null || string === '') {
    return '';
  }
  return string.replace(/\w\S*/g, function (txt) {
    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  });
}

const output = toTitleCase("javascript is very easy to learn");
console.log(output);</code></pre>



<p>Output</p>



<pre class="wp-block-code"><code class="">Javascript Is Very Easy To Learn</code></pre>



<p></p><p>The post <a href="https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-convert-a-sentence-to-a-title-case-in-javascript/">How to convert a sentence to a Title case in JavaScript</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/javascript/javascript-tricks/how-to-convert-a-sentence-to-a-title-case-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
