Jump to content

Recommended Posts

Hi,

I've tried googling around to find the answer to what I imagine is a fairly easy question, but nothing seems to have worked so far.

I'm running Apache, PHP and Access (mySQL didn't install correctly for some reason.)

In my Access DB, I have date fields, with various data in them, displaying in Access as:

e.g.: 31 March 1985

When I pull that out of the database by PHP, it displays it as:

e.g.: 1985-03-31 00:00:00

Someone suggested doing echo (date("j M Y", strtotime('dteDate'))); - but this just outputs 01 Jan 1970 to the screen.

I'm also having a similar problem with times, with DB contents being:

e.g.: 00:13:13

... but displaying on screen as:

e.g.: 1899-12-30 00:13:13

I'd like to display both of these in the format they exist in within the DB. If anyone can help I'd really appreciate it.

Cheers!
Link to comment
https://forums.phpfreaks.com/topic/34491-newbie-question-on-date-formatting/
Share on other sites

It depends on how you store the information in the database. Check the design view of the table to see how the data is stored, it sounds like you are storing the date in a Medium Date format. Change it to general date... essentially becomes a timestamp field, then you can use the date("<format here>", $date).
It now displays in Access as 31/03/1985 rather than 31 March 1985 as before. It still displays on-screen as 1985-03-31 00:00:00.
Time continues to display in Access as 00:13:13, but displays on-screen as 1899-12-30 00:13:13.

I am trying to get them to display as 31 March 1985 and 00:13:13.

Cheers.
So i take it, that you are having to different columns then? If you only require a single date/time i.e. 1/16/2007 00:13:13 store all that information in one field. then you can just format the field as you desire use: http://ca3.php.net/manual/en/function.date.php as a reference.
Thanks. I've seen this link before when I was originally investigating it, but I am having difficulty understanding how to pass the variable into the expression, as all the examples seem to refer to formatting the current date/time.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.