Skip to main content

Posts

Showing posts from October, 2020

React native Expo get current location of a user

Expo get current location of a user  Expo is a very useful tool to create a mobile application using react native. it handles many complicated things like publish, generate certificates ,access camera , location etc. To get the location of a user , we need to install expo-location package so to install it please open terminal/cmd in current project folder and run below command   expo install expo-location above command will install expo location package. This package handles ask location permission, get long/lat details , get last location , current location etc. How it works ? To get access of user's current location we need to ask for permission to user by using Location.requestPermissionsAsync() function , this function will show a permission popup to user so user can allow it, If user reject it then we cannot get current location. Once user allow us to access location then we will use location package another function Location.getCurrentPositionAsync(), this function will retur

Set Timezone in laravel or get current time based on different timezones

 Set Timezone in laravel or get current time based on different timezones   Today we will learn how to set timezone globally in laravel and also we will learn how to get time of any timezone.   Laravel: Change Timezone globally Go to YOUR_PROJECT/config/app.php and open app.php and scroll to timezone section (line number 70) then you can see code like below 'timezone' => 'UTC', replace it with any timezone that you want to apply.To view or search a timezone you can check this PHP official documents . For example i want to change timezone to America/Vancouver so after changes my code is looking like below. 'timezone' => 'America/Vancouver', Now save this and print current time using date('Y-m-d H:i:s") function. Laravel: Get Current time based on any timezone Here we will use Carbon to get current time. So copy the below code and run it and you will see current time based on timezone you have passed. $currentTime= Carbon::now('America/V