Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    Why is it that...

    now php is a great language and it has loads of really useful functions, particularly date functions - why isnt there any php functions to convert a mysql date/date-time into a unix timestamp so it can be formatted like a normal date?
    The code behind the process isnt difficult... so why isnt it there?
    In 5 versions of php I cant believe no-one has thought of it - so there must be a reason for it.

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mysql also has many useful functions, http://dev.mysql.com/doc/refman/5.0/...html#id2716133
    Code:
    SELECT FROM_UNIXTIME(your_date) FROM table
    you may also want to read about mysql's date_format function.
    Last edited by fci; 06-16-2006 at 07:40 PM.

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    that assumes the date is coming from an sql database

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, obviously but you asked about mysql not any other database system.

  • #5
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    In the situation where you have a dump from a mysql database (that you have no access to yourself) I can see a PHP function being handy...
    (speaking nicely to the people who provide the dump and getting it in the format you want would be better though...)

  • #6
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    strtotime() accepts MySQL-formatted dates.

  • #7
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Quote Originally Posted by Kid Charming
    strtotime() accepts MySQL-formatted dates.
    It does?! Bonus! I tried to read the document about the formats it accepts but it made my head spin.

    The 'mysql date format' is just the IS0 8601 international date format. Our data sources use it because in travel it is particularly important to have a standard date format. I simply called it the mysql date format because more people would know what that was than would understand ISO8601.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •