RE: Date/time format?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason wrote:
> Hi Everyone,
> 
> First off, I'm using PHP 5.2.0 and apache 1.3.33
> 
> I am trying to figure out what format a string is in in a database.
> It's a timecard system that I have found on-line and I am attempting
> to figure out how to write a script that would give me everyones
> timecard for the month on one screen I can print out for accounting
> to use. Below is an example of one of the lines in the database, What
> I'm really interested in is how it represents the "day".
> 
> user           day                job_name
> minutes     sequence
> 
> root   1171774800   Production & technology Manager
> 990             3
> 
> I have not been able to find ANY info about that format, other then
> other people using it in blogs. I think I can figure out the rest as
> I go if I know how to decode the day. Any help or pointers to the "M"
> would be GREATLY appreciated! :)

That is a UNIX timestamp, which is the type of date that the php date()
function takes as a 2nd parameter.  So for example,

<?php
	echo date("m/d/Y", $row['day']) // Output: 02/18/2007
?>

You can also format it in the query like so:

mysql> SELECT FROM_UNIXTIME(day) AS theDate FROM myTable;

Output: 2007-02-18 00:00:00

If you want to insert new records in the table you can either use time() in
php, or UNIX_TIMESTAMP(NOW()) in the query.

HTH,

-B

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux