MySQL date format
Anyone know if you can store the date in MySQL in the "normal" format?
Currently it stores dates as YYYY-MM-DD, which is odd, and a particular pain when using the ASP date function.
Anyone any ideas, other than creating a function to read or store the standard format?
Currently it stores dates as YYYY-MM-DD, which is odd, and a particular pain when using the ASP date function.
Anyone any ideas, other than creating a function to read or store the standard format?
function getdate(epoch)
'converts unix epoch date to UK date / time format...
getdate = dateadd("s", epoch, #1970-01-01#)
end function

Dates in ASP depend on server locale. I've not had any problems with them, but then again I use either my own servers or Titan's, which are correctly set up for the UK.
'converts unix epoch date to UK date / time format...
getdate = dateadd("s", epoch, #1970-01-01#)
end function

Dates in ASP depend on server locale. I've not had any problems with them, but then again I use either my own servers or Titan's, which are correctly set up for the UK.
Thats why I have also never had any probs then, all hosted with Titan 

Cheers Ady, where to use it then? Presume that will read the date format from the db, then change it for displaying. I will also need an input function for adding the date as well.


Cheers Ady, where to use it then? Presume that will read the date format from the db, then change it for displaying. I will also need an input function for adding the date as well.
if you're just inserting things as created into mysql you just do
insert into table (date) values(NOW()), which will give you now, however you've almost definitely got to edit the dates I suspect which means creating a function to do it unfortunately.
If you were using PHP:
insert into table (date) values(NOW()), which will give you now, however you've almost definitely got to edit the dates I suspect which means creating a function to do it unfortunately.
If you were using PHP:
Code:
/*
Calculate unixtime from a MySQL DATETIME
*/
function unixtime_from_mysql($mysql_date) {
if($mysql_date) {
list( $date, $time ) = split( " " , $mysql_date );
list( $year, $month, $day ) = split( "-" , $date );
list( $hour, $minute, $second ) = split( ":" , $time);
$unixtime = mktime( $hour , $minute , $second , $month , $day , $year );
return $unixtime;
} else {
return 0;
}
}
/*
Calculate a MySQL format date from unixtime
*/
function mysql_from_unixtime($unixtime) {
if($unixtime) {
return date("Y-m-d H:i:s",$unixtime);
} else {
return "0000-00-00 00:00:00";
}
}
Scooby Regular
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
how about simply...
temp = "2003-06-20"
mysqldate = Right(Date,4) & "-" & Mid(Date, 4,2) & "-" & Mid(Date, 7,2)
Wscript.echo mysqldate
AspDateFromDb = Right(temp,2) & "/" & Mid(Temp, 6,2) & "/" & Left(Temp ,4)
wscript.echo AspDateFromDb
temp = "2003-06-20"
mysqldate = Right(Date,4) & "-" & Mid(Date, 4,2) & "-" & Mid(Date, 7,2)
Wscript.echo mysqldate
AspDateFromDb = Right(temp,2) & "/" & Mid(Temp, 6,2) & "/" & Left(Temp ,4)
wscript.echo AspDateFromDb
Trending Topics
Thread
Thread Starter
Forum
Replies
Last Post





)
