Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
I used to use a website from the RAC to gather todays fuel prices, but they've changed the format and now it's all javascripted. Anyone fancy having a look and see if they can extract just the price of diesel in a usable format? Here's the website.
https://datawrapper.dwcdn.net/oDTQ2/48/
Ideally something in php as the rest of my coding is already using that.
Massive thanks
In the end the data seem to come from:
https://static.dwcdn.net/data/oDTQ2.csv?v=1646751660000
The trick the is to discover what the number behind the v parameter stands for. This is a time, in milliseconds, since the Unix Epoch (January 1 1970 00:00:00 GMT). In this case it is "2022-03-08 07:01:00.000". I think you need to update that number to get the correct prices.
Oh, I simply used the developer tools of my browser to check what was downloaded for this page. And saw one file with this response:
Unleaded,Super unleaded,Diesel,LPG
156.37,167.75,162.28,80.08
pence per litre,pence per litre,pence per litre,pence per litre
↗ Likely to rise,↗ Likely to rise,↗ Likely to rise,
7 March 2022,,,
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I know how to use the sun info function to get some info about the sun, but it doesn't offer a way to get the azimuth for a given date/time/location. Specifically, I want to get the azimuth at sunset to display in a graph where I show the length of day and sunrise/sunset.
I've seen at least one answer that partially applies, but it's a long and complicated function that calculates a whole lot of things I don't need. Since I'll need to calculate the azimuth for 365 days, I think this will add a lot of processor load and time in generating the chart.
I'm hoping for a simpler formula that will provide just the azimuth for a lat/long and timestamp.
You can use a tiny PHP library called SunCalc. SunCalc is a tiny PHP library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.)
Here you can find the lib and exemples : Source
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Can anyone explain me the concept of implementing time ago like facebook
in php. I dont want code. I want to know the flow like database field type, whether to use UTC time stamp and to convert to local time.
Thanks
It is all about your users location. If you have users only at a single timezone, then no need of conversion. But if your users are at different time zones, then you require a conversion.
In the second scenario, covert and save time in DB as UTC, then according to each user location, convert time during fetch.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a database of national park names (Alcatraz Island, Death Valley, Biscayne, etc.) which all have coordinates.
What's the simplest way for me to match the closest park in my database to their current location whether on a mobile device or on a desktop?
You can definitely use Google's Geolocation API to get the user's current location, then with some Javascript, you can determine the closest park.
Don't know what database you're using, but you might look into PostGIS, an extension to Postgres designed to handle geographical data. You would be able to query the database for the closest locations to a certain point. The algorithms for doing so are built in to PostGIS. Otherwise, you might need an external library to do the calculations.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a project that requires me to develop a website say like ebay or craigslist where users will be uploading ads and items for sale or maybe advertisement purposes. I want the users to have an option of duration that how long they would want their items to remain on the website. Let say the options are 7 days, 15 days and 30 days, if a user selects 15 days for his/her item to remain on the website, I want a simple and reliable solution that automatically deactivates or removes this specific item from the database after 15 days at exactly the same time of upload. (Must be accurate up to minutes and even seconds). Since I love php so much, I would also love if the answer is simply possible in php. Anyway, if there is another solution more reliable let me know it. I have been considering setting a $_SESSION[] and then destroying it after the time limit but I have this feeling that it may not be the best approach available. Whatever,,,,, Please help me out, Please explain. Thank you in advance.
This may help you.
DELETE FROM table WHERE delete_date >= (CURDATE() - INTERVAL 7 DAY);
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Sorry if this has been ask but i can't find anything about this on the form,
I am making a shipping calculator and i get csv files from my courier with rate and place (the calculator is made in php),my question is - what is best to read the CSV file in as an array or import the CSV to Mysql database and read the data that way?
If anyone has some experience with this type of situation and won't mine telling me the best way to go about this that will be so great.
I have not tried anything because i would like to know what the best way is to go about this.
Thanks for reading.
Won't this depend upon how many times a day you need to access the data, and how often the shipping data is updated?
eg if the shipping data is updated daily, and you access it 10000 times per day, then yes it would be worth importing it into a db so you can do your lookups.
(this is the kind of job sqlite was designed for btw).
If the shipping data is updated every minute, then you'd be best grabbing it every time.
If the shipping data is updated daily, and you only access it 10 times, then I wouldn't worry too much - either grab it an cache the file then access it as a PHP array.
Sorry, but I am not familiar with the data feed in question.