I have been searching for that on google all morning. Can’t find it. That’s why I am back here asking for help.
Just checking, in an actual RDBMS you can. I don’t deal with anything in access and haven’t for a number of years and wasn’t sure.
The example Jim showed will take a time string, that comes from access, and convert it to a datetime object. You can then format it how you wish to display the new format.
That code is plug-and-play to convert your date string to the format you want. Just change my first line with your line here. It was an answer to this question:
[hr]
Your second question - how to get it properly from the db - is a much better approach, so I suggest you go that route.
Yeah that didn’t work either. Instead it just put today’s date at the top of my page.
$RatingsLastUpdated = odbc_result($rs,“RatingsLastUpdated”);
$dateTime = new DateTime($RatingsLastUpdated);
echo $dateTime->format(‘m-d-Y’); // 08-14-2015
The database contains dates that I manually enter. Those appear on the site as this field: $RatingsLastUpdated. However, that field is showing up as this on the page: Ratings Last Updated: 2015-08-14 00:00:00.000.
Here is the code for that section that pulls it in.
Ratings Last Updated: <?= $RatingsLastUpdated ?>
|
I just want anything aside from the d/m/y to go away on the site.
So, it works fine. Usually when you copy/paste code you need to apply it to your use-case. Just echoing it where I did will of course echo it wherever that code is pasted. Which in this case above the rest of your output.
You are still echoing out $RatingsLastUpdated on the page, which is the value returned from the DB. To use the solution I pasted you need to change that to echo the formatted datetime value.
But, as said previously. You should change the query to return the correct value. I have no experience with MSSQL so won’t get into that.
Thanks Jim. I really don’t know what you are talking about but what I can tell you is that I cannot change anything with the SQL itself. I cannot mess with the backend and don’t have access to it. I have to do everything on the PHP webpage itself.
Ok, no problem - outputting the formatted date is fine as well. It’s just generally recommended to get the wanted result set as early as possible in the code.
Thanks. I’m giving up on this. I need an expert. Going to find a freelancer.