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 8 years ago.
Improve this question
Which is the best way to store data which come from the entire world?
I was thinking, for instance, to store the time() without timezone and then convert it every time.
Could be right? Is there a method to detect timezone of a request?
For that you can save a Unix Timestamp in your database.
http://php.net/manual/en/function.time.php
http://dev.mysql.com/doc/refman/5.5/en/datetime.html
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
So every people have the same timestamp format without a timezone.
Otherwise you have to store a Datetime field and the Timezone and calculate the correct value.
Related
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,,,
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 3 years ago.
Improve this question
I got this .csv file where I have employee number, name and birthday. Birthday comes in dd-mm format (I live in Mexico), how can I convert it to proper date, so I can call date function date('y-m-d', $date) in order to store it in the database?
You can't! At least not reliably. A date must contain the year.
Consider this example:
$dt = DateTime::createFromFormat('d-m', '29-02');
echo $dt->format('Y-m-d'); // 2019-03-01
If an employee's birthday is on the 29th of February and you store it in DB as Date then you are loosing information. To keep the original information intact you need to store it in the format you have received it in, as a VARCHAR field of suitable length.
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 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 8 years ago.
Improve this question
I'm curious what will be the output of this code? I can't understand what the time() is for, is that indication for the system time?
I edited the code sorry. This is the REAL code
$testnum = 4053000
$timetest = trim($testnum)
$rawnum = time() - ($timetest * 60);
$diffdate = date('d/m/Y H:i:s', $rawnum);
Thank you in advance!
The time() function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). So what you see is an integer in seconds.
You define your timezone in the PHP.ini
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
How do I store dates and time from an online form I have into an SQL database using PHP? The date/time function is working quite ok.
You should use the datetime datatype for your requirement. It will store both the date and time from your input field based on your query.
For retrieving the datetime you can use the mysql's date_format() function or PHP's date() function. The datetime will always be stored according to the server's time and not on the clients time.