|
-
Dec 19th, 2006, 08:18 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Date format
Its back to basics i think 
My datae is stored in MySQL database in this format DD-MM-YYYY HH-MM-SS (the timestamp format)
I need to format this and preferable outside of the MySQL query statement, now what formatting function do i use, i have tried various, with little result.
Cheers people
-
Dec 19th, 2006, 08:57 AM
#2
Thread Starter
Frenzied Member
Re: Date format
I have solved the problem by creating a function to take the time from the timestamp, split it up, and format it using date and mktime. I have included it for future refernce,m if anyone spots an issue, gives us a shout 
PHP Code:
function format_date($timestamp_date='')
{
if($timestamp_date=='')
{
// Return if no variables passed
return;
}
else
{
// Split up date and time
$date_time = split(" ", $timestamp_date);
// Split up date
$date = split("-", $date_time[0]);
// Split up time
$time = split("-", $date_time[1]);
$result=date("l jS F Y", mktime($time[0], $time[1], $time[2], $date[1], $date[2], $date[0]));
}
return $result;
}
-
Dec 19th, 2006, 04:24 PM
#3
Re: [RESOLVED] Date format
if I were you, I'd just store them as unix timestamps and convert them to whatever I need to at runtime. It depends what you're comfortable with, I guess.
-
Dec 20th, 2006, 09:21 AM
#4
Thread Starter
Frenzied Member
Re: [RESOLVED] Date format
Yes i was told this before by visualad, however im using phpMyAdmin, and i cant seem to find the unix timestamp option :O
-
Dec 20th, 2006, 10:12 AM
#5
Re: [RESOLVED] Date format
when you're creating a table you just need to make your date fields an integer that holds 11 figures (ie: int(11)) instead of "date" or "timestamp" types.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|