How to Install and Use Moment JS in Laravel?
How to Install and Use Moment JS in Laravel?
By Hardik Savani June 11, 2020 Category : LaravelThis tutorial will provide example of how to use moment js in laravel. step by step explain how to install moment in laravel vue. we will help you to give example of install moment in laravel. This article will give you simple example of use moment js in laravel.
In this example, i will show you step by step how to install moment in laravel mix. i will give you two example of installing moment in laravel. one will be using npm command using laravel mix and another example will using cdn js.
You can easily use moment in laravel 6, laravel 7, laravel 8 and laravel 9 version. so let's see bellow step be step process.
1) Install Using Npm
first, we will install laravel fresh version. so let's run bellow command:
Now, we need to install npm in our new laravel application. so let's simply run bellow command. this command will create "mode_modules" folder in your root directory and store all npm module there.
After that we need to install font awesome library using bellow npm command. so let's run bellow command:
After install successfully, we can use in our app.js file. so let's import as bellow:
resources/js/app.js
Now we are ready to run npm dev command, so let's run bellow command:
Here, we will use generated app.css file in our blade file as bellow:
resources/views/welcome.blade.php
Now you can run your application and see on home page. You will get output as bellow:
2) Install Using CDNJS
here, we will use cdn js file for adding moment js, so let see bellow file code:
resources/views/welcome.blade.php
Read Also: How to Install and Use Font Awesome Icons in Laravel?
I hope it can help you...
Last updated
Was this helpful?