FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Spliting Date





DanielXP
Ok a date saves into a db and i want to split it.

this is how it goes into the db

DD/MM/YYYY

and i want it to split so like

$DD = "DD";
$MM = "MM";
$YYYY = "YYYY";

eg today

21/08/2006

$DD ="21";
$MM = "08";
$YYYY = "2006";

Is there any way of doing this?

Thanks!
ganbate
DanielXP wrote:
Ok a date saves into a db and i want to split it.

this is how it goes into the db

DD/MM/YYYY

and i want it to split so like

$DD = "DD";
$MM = "MM";
$YYYY = "YYYY";

eg today

21/08/2006

$DD ="21";
$MM = "08";
$YYYY = "2006";

Is there any way of doing this?

Thanks!


use explode function.

example :
Code:

$today = "21/08/2006"

$date = explode("/", $today);

$DD = $date[0];
$MM = $date[1];
$YYYY = $date[2];
DanielXP
Parse error: parse error, unexpected T_VARIABLE

on line

$date = explode("/", $today);

EDIT: Fixed thanks mate!
hexkid
I'd do it a bit different than ganbate

SQL
Code:
select year(date_column), month(date_column), day(date_column) from ...


PHP
Code:
$DD = $dbvalue[2];
$MM = $dbvalue[1];
$YYYY = $dbvalue[0];
Related topics
10 Reasons to Date a Hockey Player
FTP - file last modified date
keep your adblocking up to date
When dating a new girl, how long do you wait before you kiss
PHP date() format for atom in php 4
A ActionScript,showing a running date.
Quels sous-forums aimeriez-vous avoir??
Date wrong on pc
Guess the Windows Vista Launch Date(Win Prizes!!!!)
Ten reasons you should date a geek
Is there a release date for ET:QW
mySQL - Day, date, month, year, time Output/Input
What date format do you prefere with MySQL?
date() function
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.