In addition to Jaxon's answer, I am going to explain a bit more.
The first one is in informal form. This means, you can use this type (informal Japanese) with people who is close to you like your friends and family members. It's usually not polite to use informal with people whom you don't know or have just met and with the ones who is older than you. That said, it's definitely polite to use formal Japanese (your second sentence) to people whom you just met, who is older than you and whom you want to show respect to.
Hope my explanation was useful! Let me know if you have more questions...Have fun learning Japanese!
\(^_^)/