Part 15 - Working with Dates from Database [How to Build a Blog with Laravel 5 Series]

preview_player
Показать описание
See me in my natural habitat. Because of my busy schedule today I didn't have time to make a polished video for you guys like usual, so I am experimenting with a more Raw video where I make mistakes and have fewer edits. I go on a few tangents but decide to not edit them out. I hope you enjoy the video regardless of its potential flaws.

Dates in MySQL are stored as a string. However, PHP works with dates as a UNIX Timestamp. This is an integer of the number of seconds that have passed since Jan 1, 1970 UTC. Before we can do anything with dates, we need to first convert our database time string into something that PHP will work with.

To get a UNIX timestamp from a string you need to use strtotime() function from PHP. This converts it into an Integer unix timestamp.

Then to get the timestamp into a user friendly view, we need to use the PHP Date() command. This command will accepts a string formula as its first argument and a unix timestamp as its second argument. You can create the formula you want by looking on the PHP Date() website. I have the link below.

Next we work with Html::linkRoute() which allows us to give it a named route and it creates an html anchor tag (aka link). The first argument is the named route (string), the second is the value of the anchor tag, the third is an array (empty if no url params, or add the params in order), and the final argument is another array of all the options you want to use.

Last we talk about a fun app that downloads documentation for offline use. It is called Dash. Link below.

--- DOWNLOAD SOURCE CODE ---

--- LINKS ---

Bootstrap Well Docs:

PHP Date() Docs:

PHP StrToTime Docs:

Html::LinkRoute() Docs:

Dash iOS and OS X App:

--- MORE FROM THIS SERIES ---

Next video [Part 16]: Coming Soon

--- FOLLOW ME ---

Subscribe for New Releases!

(ask me questions!)

--- QUESTIONS? ---

Leave a comment below and I or someone else can help you.

Thanks for all your support!

---

Tags: Database date with PHP. Laravel 5.2 Framework Tutorial Easy to learn. Best tut about Laravel. Build a blog with Laravel Tutorial. Beginner tutorial. How to video. PHP framework easy best tutorial. Laravel 5 coding in PHP with Alex.
Рекомендации по теме
Комментарии
Автор

Jacurtis, you could do no wrong my friend. Please do not aplogize for any slip ups. You have been incredibly generous with your time and expertise. I think that I speak for most everyone who has been following this series. Keep up the great work.

Osteele
Автор

Code for not using the form helper.
<div class="row">
<div class="col-sm-6">
<a href="{{ route('posts.edit', $post->id) }}" class="btn btn-primary btn-block">Edit</a>
</div>
<div class="col-sm-6">
<a href="{{ route('posts.destroy', $post->id) }}" class="btn btn-danger btn-block">Delete</a>
</div>
</div>

sodomousprime
Автор

This series is simply incredible. I cannot imagine those few people who disliked it!
You got one permanent subscriber.

vishalsharma-bpzu
Автор

10 years ago I built an entire commercial content publishing system in php using MVC all from the ground up and I can fully appreciate the complexity of Laravel. With that said, I really applaud this series. You have such a clear grasp on the techniques and deliver very difficult material to a greatly varied audience. Heck I wish I was this comfortable on camera. Bravo Mr Curtis...bravo sir!!

MakerMark
Автор

Man, this raw episodes I like most. The reason is that when you are new to webdev it is very helpful not just learn stuff about tech, but learn how webdev thinks and what is he/she doing to get the result. Otherwise you just see a smart genius moving like Neo in Matrix. Thank you! Do more RAW episodes. RAWPISODES!

candybar
Автор

You made great videos and I do believe it is very helpful for most of us! I am from China, I can not find out so great tutorials in China, you helped me a lot! Thanks so much! You are taking your time and teach for free, I am so respect!

dongzhe
Автор

I'm glad you mentioned Dash! It's the best tool I have with regards to programming. I keep it at my desk on my iPad while programming at all times. I'm looking forward to seeing more of your videos on here.

One thing I would love to see. Is application code planning. If someone has an idea for an app what should they to utilize documentation and resources to plan what they need of a frameworks codebase before they start coding etc. If that makes sense. I find that this is missing in a lot of tutorials and it always seems magical that the instructor just builds an app without mentioning how they knew to utilize certain patterns of code. This is great, it introduces patterns and what people are in for using a framework but doesn't explain certain rules. A tutorial like this would really allow people to learn how to program creatively rather than templated from what they see on Youtube and so on.

fragileglass
Автор

I dont care if you keep making tutorials while brushing your teeth. you are doing good to the world my good man..keep posting.

mrmanualways
Автор

i have been watching you since the first episode, i am fallowing you in every video.Yours tutorials rocks.Thanks a lot!

erjonhazizaj
Автор

if you want to use Html use this: <a href="{{ route('posts.edit', $post->id, 'Edit') }}" class="btn btn-primary btn-block"> Edit</a>

jordanyrosario
Автор

Being a PHP developer for years but never used Laravel. I just found you a few days ago and I am already addicted to this series and binge-watching through my holiday.
Btw I dropped Eclipse as my editor in favor of Atom.

robdorn
Автор

I'm a big fun, from zero in laravel to 90% and still progressing ...nth% Thank you so much for being raw and hands on!

AlphonceOchieng
Автор

Thanks! Learning alot from you! Indeed, among other things you have in your videos, I have never used definitions before. Here to stay till video 54!!! Thanks again.

josephnduati
Автор

I am watching your every eps till now and It is priceless for beginners like me. Love it :)

lakpasherpa
Автор

This is the best format for a teaching video. No feelings that you are total noob when even the teacher makes mistakes.

PaulNike
Автор

i just want you to know that at this date! on the year 2017 your tutorials helped me to get a remote job as a freelancer programmer. and ill go all the way, the only diferrence is the version of laravel... but still.. you are one of THE best programing tutorials ive seen on the web since EVER! keep it up.

MJAD
Автор

Hey, he mentions the Philippines! That's my home. Shout out to PH followers. keep up Jacurtis. I've been following your tutorials since from the beginning.

raky-profile
Автор

I learned not just to script with laravel but also not to beat myself up on codes i haven't memo'ed.You're real man ! YOU THOUGHT ME LARAVEL !

kelvejimogu
Автор

hey mr Curtis i have to say i started watching your videos last week whilst deciding on whether to learn php cake or laravel i decided on laravel . at first i thought you waffled a lot but God i so so appreciate it as you cover problems that arise you may not know has happened till its too late and on reflection like a light bulb you are thats what he was babbling about earlier on!!!! . i understand a lot more following your line of thought . i love your half episodes which add to the experience without breaking from the learning curve . i even bought a macbook pro to follow you . i have always done all programmnig on pc . i can not praise your way of teaching enough and l, ook forward to your next episodes dont stop teaching .

jamescooke
Автор

Man you killing it. The way you present it and keeping the interest at top, priceless...

lutfucan