PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime ) by alexendre-maxim

View this thread on steempeak.com
· @alexendre-maxim · (edited)
$31.45
PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )
<html>
<p><img src="https://cdn.steemitimages.com/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg" width="2122" height="1415"/></p>
<p><a href="https://cdn.steemitimages.com/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg">Image Source</a></p>
<h2>Repository</h2>
<p><a href="https://github.com/php/php-src">https://github.com/php/php-src</a> &nbsp;</p>
<h2>What Will I Learn?</h2>
<ul>
  <li>You will learn the timestamp.</li>
  <li>You will learn how to get the date with format using the <code>date()</code> method.</li>
  <li>You will learn how to get and set the timezone.</li>
  <li>You will learn the <code>StrToTime()</code> method.</li>
</ul>
<h2>Requirements</h2>
<h5>System Requirements:</h5>
<ul>
  <li>Server support PHP , <a href="https://www.apachefriends.org/fr/download.html">Xampp</a> or <a href="http://www.wampserver.com/">Wamp</a> for example</li>
  <li>An IDE like <a href="https://www.sublimetext.com/download">Sublime text</a>.</li>
  <li>Browser (<a href="https://www.google.com/intl/fr_ALL/chrome/">Chrome</a> for example)&nbsp;&nbsp;</li>
</ul>
<h5>OS Support for PHP</h5>
<ul>
  <li>Windows</li>
  <li>macOS</li>
  <li>Linux</li>
</ul>
<h4>Required Knowledge</h4>
<ul>
  <li>HTML language</li>
  <li>CSS language</li>
</ul>
<h2>Difficulty</h2>
<ul>
  <li>&nbsp;Intermediate&nbsp;</li>
</ul>
<h2>Description</h2>
<p>In this tutorial we will learn the dates and times, there is no thing almost without the notion of time " publications, comments ..etc " almost all the tasks you can specify it using the dates and the time.</p>
<p>Dates in PHP have always been a fundamental issue for developers, how to store, manage, manipulate dates or time intervals, most developers will say : " the timestamp ".</p>
<p>Today we are going to see the function <code>date()</code>, is not the object date because we are going to learn the objects in the next tutorials, and we also have the timestamp, the function <code>strtotime()</code> and finally the timeZone set and Get.</p>
<h3>1- TimeStamp</h3>
<p>In PHP to use date the start was the timestamp, the timestamp is the number of seconds that have passed since January 1, 1970, &nbsp;the timestamp was at the base everything in all languages. We didn't complain too much the web was not too developed, manage dates in PHP was very common (for forums) but was not very developed.</p>
<p>With time, the timestamp has become longer and longer, with the development of the webthe use of dates is become more frequent and more complex.</p>
<p>Relational database managers such as " MySQL " or " Postgres " had already shown the power of a datatype specific to dates rather than the timestamp itself, in particular because it allowed to keep only the part "date" or the part "time" ( hours, minutes, seconds).</p>
<p><img src="https://cdn.steemitimages.com/DQmWx7BoNEaUeZy4RE2KzSG64erzipDr32TbtFrbXNYFcps/capture-20190330-160717.png" width="934" height="573"/></p>
<h3>2- Date Method</h3>
<p>The function 'date' forms or returns the date and local time of your server, it returns a date in the form of a string in the format given by the format parameter.</p>
<p>The most important thing is that this function must contain a parameter, you must indicate the display or value returned by this function.</p>
<p>The function contains the format as parameter, the format offered by PHP with several characters.</p>
<p>This function accepts a second argument that corresponds to a number of seconds since the beginning of the UNIX epoch.</p>
<p><img src="https://cdn.steemitimages.com/DQmT626qmvy34b5pkJCQQt1Xo6b4JULKt8nZik3Ys5HGprk/date.jpg" width="945" height="1848"/></p>
<h3>3- TimeZone</h3>
<p>One of the big problems when you want to manage the hours is that everyone on earth is not at the same time. Between time zone and summer time you will quickly fall into difficult problems.</p>
<p>You aren't unaware that on our good old Earth there are 24 time zones,these range from -12 to +12 through Greenwich, in order to make sure that each of your users visualize your site at its own time, you must set the time zone of your site using Timezone of php.</p>
<p>We will see the " <code>date_default_timezone_get()</code> " and " <code>date_default_timezone_set(timezone)</code> " functions.</p>
<p>The "<code>date_default_timezone_set(timezone)</code> " &nbsp;will change the default timezone, if the default timezone is Europe/Berlin, it will be with the timezone that you propose.</p>
<p>The " <code>date_default_timezone_get()</code> " will retrieve the default timezone from your system, to see and fix the problem we mentioned.</p>
<p><img src="https://cdn.steemitimages.com/DQmV296GSm7Nxjc8Uxr5z5GD3Ai4ARS6Eo1TqXfFQ5QfXjB/3.jpg" width="945" height="436"/></p>
<h3>4- StrToTime Method</h3>
<p>The " <code>strtotime()</code> " function tries to read a date in US English format in the time string, and turn it into a Unix timestamp.</p>
<p>Really the use of the timestamp is a little difficult on all if you want a date in the past, for that PHP offers this solution you can enter a date like " last year " for example in English, or something that has a relationship with time ( the time indectors we can say ) , and this function will try to understand it and return the date in place of a succession of digits that it forms the timestamp.</p>
<p>It accepts two parameters :</p>
<p>The first is the time : it's required specifies a date/time string to parse.</p>
<p>The second is now: it's optional, specifies The timestamp representing the current date, used for the relative calculation of dates.</p>
<p><img src="https://cdn.steemitimages.com/DQmYRq7zyH6mxnpAH71kVG5vUhEq4diuRgWTpyyJWKohPj6/4.jpg" width="945" height="436"/></p>
<h2>Video Tutorial</h2>
<p>https://www.youtube.com/watch?v=s7knumLeGWk&amp;feature=youtu.be</p>
<h2>Curriculum</h2>
<ul>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-11-string-methods-addslaches-chr-chop-and-chunksplite">PHP Tutorial #11 String Methods ( Addslaches, Chr, Chop and Chunk_splite )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin">PHP Tutorial #12 String Methods ( Bin2Hex, Count_Chars, Explode and Hex2Bin )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-13-string-methods-implode-join-lcfirst-ltrim-and-fprintf">PHP Tutorial #13 String Methods (Implode, Join, Lcfirst, Ltrim and Fprintf )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-14-string-methods-md5file-md5-nl2br-and-addcslaches">PHP Tutorial #14 String Methods (Md5_File, Md5, Nl2br and Addcslaches )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-15-string-methods-numberformat-ord-parsestr-print-and-printf">PHP Tutorial #15 String Methods (Number_Format, Ord, Parse_Str, Print and Printf )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-16-string-methods-quotemeta-rtrim-sha1file-and-sha1">PHP Tutorial #16 String Methods (QuoteMeta, Rtrim , Sha1_file and Sha1 )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-17-mathematical-methods-abs-acos-acosh-and-asin">PHP Tutorial #17 Mathematical Methods (Abs, Acos , Acosh and Asin )</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-18-get-and-post-methods-and-usdserver-variables">PHP Tutorial #18 ( GET and POST ) Methods and $_SERVER Variables</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-19-include-and-require-globals-variable-request-and-usdserver-variables">PHP Tutorial #19 ( Include and Require ) , Globals Variable, Request and $_SERVER Variables</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-20-the-cookie-how-to-create-modify-and-delete-a-cookie">PHP Tutorial #20 The Cookie How To Create , Modify And Delete A Cookie</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-21-the-session-how-to-create-modify-and-delete-a-session">PHP Tutorial #21 The Session How To Create , Modify And Delete A Session</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-22-the-outputbuffer-and-how-to-control-it">PHP Tutorial #22 The Output_Buffer And How To Control It</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-23-filters-part-1-filtervalidate">PHP Tutorial #23 Filters Part 1 " FILTER_VALIDATE "</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-24-filters-part-2-filtersanitize">PHP Tutorial #24 Filters Part 2 " FILTER_SANITIZE "</a></li>
  <li><a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-25-file-system-part-1-fopen-fread-fwrite-and-filegetcontents">PHP Tutorial #25 File System Part 1 " Fopen, Fread, Fwrite and File_get_contents "</a></li>
  <li>&nbsp;<a href="https://steemit.com/utopian-io/@alexendre-maxim/php-tutorial-26-file-system-part-2-and-filter-part-3">PHP Tutorial #26 File System Part 2 and Filter Part 3</a></li>
</ul>
<h2>Proof of Work Done</h2>
<p>https://github.com/alexendre-maxim/PHP-Tutorial/blob/master/date.php</p>
</html>
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 86 others
properties (23)
post_id72,293,710
authoralexendre-maxim
permlinkphp-tutorial-27-the-date-timestamp-date-timezone-and-strtotime
categoryutopian-io
json_metadata{"tags":["utopian-io","video-tutorials","video","programming"],"image":["https:\/\/cdn.steemitimages.com\/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg\/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg","https:\/\/cdn.steemitimages.com\/DQmWx7BoNEaUeZy4RE2KzSG64erzipDr32TbtFrbXNYFcps\/capture-20190330-160717.png","https:\/\/cdn.steemitimages.com\/DQmT626qmvy34b5pkJCQQt1Xo6b4JULKt8nZik3Ys5HGprk\/date.jpg","https:\/\/cdn.steemitimages.com\/DQmV296GSm7Nxjc8Uxr5z5GD3Ai4ARS6Eo1TqXfFQ5QfXjB\/3.jpg","https:\/\/cdn.steemitimages.com\/DQmYRq7zyH6mxnpAH71kVG5vUhEq4diuRgWTpyyJWKohPj6\/4.jpg","https:\/\/img.youtube.com\/vi\/s7knumLeGWk\/0.jpg"],"links":["https:\/\/cdn.steemitimages.com\/DQmR2CdPgUAaypJwbE8QhahqDxrabLTM5fHq8ZjTPcVr2fg\/bbva-open4u-herramientas-basicas-desarrolladores-php_1.jpg","https:\/\/github.com\/php\/php-src","https:\/\/www.apachefriends.org\/fr\/download.html","http:\/\/www.wampserver.com\/","https:\/\/www.sublimetext.com\/download","https:\/\/www.google.com\/intl\/fr_ALL\/chrome\/","https:\/\/www.youtube.com\/watch?v=s7knumLeGWk&feature=youtu.be","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-11-string-methods-addslaches-chr-chop-and-chunksplite","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-12-string-methods-bin2hex-countchars-explode-and-hex2bin","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-13-string-methods-implode-join-lcfirst-ltrim-and-fprintf","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-14-string-methods-md5file-md5-nl2br-and-addcslaches","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-15-string-methods-numberformat-ord-parsestr-print-and-printf","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-16-string-methods-quotemeta-rtrim-sha1file-and-sha1","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-17-mathematical-methods-abs-acos-acosh-and-asin","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-18-get-and-post-methods-and-usdserver-variables","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-19-include-and-require-globals-variable-request-and-usdserver-variables","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-20-the-cookie-how-to-create-modify-and-delete-a-cookie","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-21-the-session-how-to-create-modify-and-delete-a-session","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-22-the-outputbuffer-and-how-to-control-it","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-23-filters-part-1-filtervalidate","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-24-filters-part-2-filtersanitize","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-25-file-system-part-1-fopen-fread-fwrite-and-filegetcontents","https:\/\/steemit.com\/utopian-io\/@alexendre-maxim\/php-tutorial-26-file-system-part-2-and-filter-part-3","https:\/\/github.com\/alexendre-maxim\/PHP-Tutorial\/blob\/master\/date.php"],"app":"steemit\/0.1","format":"html"}
created2019-03-30 19:24:48
last_update2019-03-30 19:33:33
depth0
children7
net_rshares43,750,329,505,563
last_payout2019-04-06 19:24:48
cashout_time1969-12-31 23:59:59
total_payout_value23.962 SBD
curator_payout_value7.488 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length9,384
author_reputation18,057,876,007,767
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (150)
@rosatravels ·
$14.47
Hi @alexendre-maxim

This is another great addition of video tutorial to your series.

Your presentation is clear and to the point.

As for the written text, try to write short simple sentences.  People who have English as their second language tends to write run on sentences without  putting in the proper punctuation. 

Long run on sentences make it difficult for people to follow the text.  


Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/9/1-1-2-2-2-2-1-2-3-).

---- 
Need help? Chat with us on [Discord](https://discord.gg/uTyJkNm).

[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , , ,
properties (23)
post_id72,371,813
authorrosatravels
permlinkre-alexendre-maxim-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190401t110107564z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["alexendre-maxim"],"links":["https:\/\/join.utopian.io\/guidelines","https:\/\/review.utopian.io\/result\/9\/1-1-2-2-2-2-1-2-3-","https:\/\/discord.gg\/uTyJkNm","https:\/\/join.utopian.io\/"],"app":"steemit\/0.1"}
created2019-04-01 11:01:09
last_update2019-04-01 11:01:09
depth1
children2
net_rshares19,339,847,781,672
last_payout2019-04-08 11:01:09
cashout_time1969-12-31 23:59:59
total_payout_value10.917 SBD
curator_payout_value3.552 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length850
author_reputation446,683,592,150,961
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (14)
@utopian-io ·
Thank you for your review, @rosatravels! Keep up the good work!
properties (22)
post_id72,496,585
authorutopian-io
permlinkre-re-alexendre-maxim-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190401t110107564z-20190403t204600z
categoryutopian-io
json_metadata{"app":"beem\/0.20.17"}
created2019-04-03 20:46:03
last_update2019-04-03 20:46:03
depth2
children0
net_rshares0
last_payout2019-04-10 20:46:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length63
author_reputation152,913,012,544,965
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@alexendre-maxim ·
Thank you @rosatravels, Yes to understand better, sentences must be simple.
properties (22)
post_id72,873,268
authoralexendre-maxim
permlinkre-rosatravels-re-alexendre-maxim-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190410t232636173z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["rosatravels"],"app":"steemit\/0.1"}
created2019-04-11 00:26:15
last_update2019-04-11 00:26:15
depth2
children0
net_rshares0
last_payout2019-04-18 00:26:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length75
author_reputation18,057,876,007,767
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-ua ·
#### Hi @alexendre-maxim!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
post_id72,373,606
authorsteem-ua
permlinkre-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190401t113905z
categoryutopian-io
json_metadata{"app":"beem\/0.20.19"}
created2019-04-01 11:39:06
last_update2019-04-01 11:39:06
depth1
children1
net_rshares0
last_payout2019-04-08 11:39:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length294
author_reputation23,203,609,903,979
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@alexendre-maxim ·
Thank you @steem-ua

Posted using [Partiko Android](https://partiko.app/referral/alexendre-maxim)
properties (22)
post_id72,830,757
authoralexendre-maxim
permlinkalexendre-maxim-re-steem-ua-re-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190401t113905z-20190410t105838207z
categoryutopian-io
json_metadata{"app":"partiko","client":"android"}
created2019-04-10 10:58:48
last_update2019-04-10 10:58:48
depth2
children0
net_rshares0
last_payout2019-04-17 10:58:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length97
author_reputation18,057,876,007,767
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@utopian-io ·
Hey, @alexendre-maxim!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
post_id72,408,162
authorutopian-io
permlinkre-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190402t014637z
categoryutopian-io
json_metadata{"app":"beem\/0.20.17"}
created2019-04-02 01:46:39
last_update2019-04-02 01:46:39
depth1
children1
net_rshares0
last_payout2019-04-09 01:46:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length597
author_reputation152,913,012,544,965
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@alexendre-maxim ·
Thank you

Posted using [Partiko Android](https://partiko.app/referral/alexendre-maxim)
properties (22)
post_id72,830,739
authoralexendre-maxim
permlinkalexendre-maxim-re-utopian-io-re-php-tutorial-27-the-date-timestamp-date-timezone-and-strtotime-20190402t014637z-20190410t105812581z
categoryutopian-io
json_metadata{"app":"partiko","client":"android"}
created2019-04-10 10:58:12
last_update2019-04-10 10:58:12
depth2
children0
net_rshares0
last_payout2019-04-17 10:58:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length87
author_reputation18,057,876,007,767
root_title"PHP Tutorial #27 The Date ( timestamp, date, timezone and strtotime )"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000