Click to See Complete Forum and Search --> : saving Time but query return date and time
terry81
09-21-2004, 03:44 AM
Hi there,
I used the following codes to get the time.
($sec,$min,$hr) = localtime();
$time = "$hr:$min";
I am using a ms access database. I have this field called TIMEIN with date/time data type.
When i insert $time into the field, TIMEIN and when I opened up the database to check if the entry is correct. Yes. the time is saved.
But when I use PHP to query to display all time, it return me with date also!! and the date is dated back from 1800+yr
what sld i do?
I don't understand your problem, exactly -- shouldn't it return the same date that Perl does? By the way, this seems more like a PHP question than a Perl one...
terry81
09-21-2004, 08:28 PM
well Jona,
let's say if I want to extract only time in hr and min using perl and save into a ms access w date/time data type...how do I do that?
i am using:
($sec, $min, $hr) = localtime();
$time = "$hr:$min";
print "$time";
when I print it out, i will get something like 8:50. When saved into access, it will appear as 8:50 AM in the record.
But when I query with PHP, it comes with date also! this is what i mean. It doesnt matter whether it is php or perl way of querying. I think something wrong with the way i extract time with perl.
Simply said, I just want to save TIME into a record with date/time as data type.
Can u help?
Just add more variables to the list to get the rest of the date. See: <http://perl.about.com/library/weekly/aa051601a.htm>.
terry81
09-21-2004, 10:47 PM
thanks for the link but sadly, it only mention how to extract date.
all i want is time.
in my database, the value saved is time but just dont get it why the date appear itself when queried.
Split the returned string, then, disregarding the date and returning only the time. What do you get when you retrieve it from the database?
terry81
09-22-2004, 12:37 AM
the funny thing is when i open ms access and look inside the database...only the time are saved...so by right there sldnt be anything else appear.
Try using something like the following, assuming "$date" is the variable containing the result from the MS Access database (since I only know Perl, not MS Access).
($sec, $min, $hr) = $date;
print "$hr:$min";
If it doesn't work, I don't know what to tell you, I've never worked with MS Access and Perl.