This is a discussion on "PHP dates" within the PHP Forum section. This forum, and the thread "PHP dates are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP dates
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
PHP dates
In my Blog this code gets the date
2007-09-04 17:03:47 How do i reformat that
__________________
The Net is Dying | Fan Rage | We are Battlefield heroes - BFH Forum Vanilla Source - Vanilla Help, and mods
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
|
|
|||
|
Re: PHP dates
Ah, I had this problem. You've got your MySQL formatted to a DATETIME value presumably?
You need to convert it to a Unix Timestamp. This nifty function can do that for you...
That's how I'm doing on my new website. Others may have better ways. Hope this helps. |
|
||||
|
Re: PHP dates
Sorry were do i add that
__________________
The Net is Dying | Fan Rage | We are Battlefield heroes - BFH Forum Vanilla Source - Vanilla Help, and mods
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
|||
|
Re: PHP dates
You can declare your function anywhere, although you need to declare it before you call it.
I've just noticed I've missed out a closing parenthesis on that function. Once you've declared you function you need something like...
I'm not one hundred percent sure that willl work as I'm at work at the moment. Work on that basis and with a little bit of Googling you should be alright. |
|
||||
|
Re: PHP dates
Quote:
__________________
The Net is Dying | Fan Rage | We are Battlefield heroes - BFH Forum Vanilla Source - Vanilla Help, and mods
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
|||
|
Re: PHP dates
You need the curly bracket at the end of your convert_datetime function!
|
|
||||
|
Re: PHP dates
i get
01/01/70 : 01:01:00 now how would i get rid of the wasted 0's
__________________
The Net is Dying | Fan Rage | We are Battlefield heroes - BFH Forum Vanilla Source - Vanilla Help, and mods
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
|||
|
Re: PHP dates
There's a simlpler way to do this:
30/12/07 have a look at 'Paramaters' to see how to format the date: http://uk2.php.net/manual/en/function.date.php |
|
|||
|
Re: PHP dates
If only I'd found the "strtotime" function last week when I spent ages to trying to find out a way of doing this! Cheers Jim!
Alas Simon, Jim's way is much easier. Although if you're getting a 1/1/1970 date then your date would appear to have a value of 0. |
|
|||
|
Re: PHP dates
lol, I feel your pain.
|
|
||||
|
Re: PHP dates
thanks that is much easyer
__________________
The Net is Dying | Fan Rage | We are Battlefield heroes - BFH Forum Vanilla Source - Vanilla Help, and mods
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
||||
|
Re: PHP dates
Here's another solution using preg_match:
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
![]() |
| Tags |
| date, php |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Days between 2 Dates | birdy247 | JavaScript Forum | 1 | Apr 19th, 2007 19:55 |
| Querying Dates | Steve Mellor | Databases | 1 | Apr 13th, 2007 14:59 |
| printing out dates | riotman | Classic ASP | 0 | May 23rd, 2006 20:47 |
| dates in SQL | spinal007 | Databases | 3 | Nov 10th, 2004 09:32 |
| dates | benbacardi | Classic ASP | 2 | Sep 14th, 2004 16:18 |