Search code examples
phpmysqldatecharacterlimit

PHP-MySQL: Limit data with a specific characters


I researched the forum but could not find a solution.

I have a date in my DB and date format is not like Y-m-d H:i. And the table is not set as date. I need to fetch the date from db but I just need Y-m-d. My date format like: 9.12.2014 18:34. I just need 9.12.2014. I want my query to stop when it sees the blank/space. I'm fine with the d.m.Y format.

Is there a way?


Solution

  • I think I found the solution:

    $email  = '[email protected]';
    $user = strstr($email, '@', true); // after PHP 5.3.0
    echo $user; // name