LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2008, 12:23 PM   #1
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
php/mysql datestamps


i have a database program that inserts datestamps into a database
they look in the database like
Code:
1219782825
how do i read that with my own php script as a date/time instead of the raw date stamp?
 
Old 09-16-2008, 01:04 PM   #2
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
I don't know what that number represents; For a MySQL like database the tutorial describes the date datatype.

By looking at the number and trying "semirandom" stuff; perhaps to get the year in php


$year = floor(1970 + $stamp/(60*60*365*24))
$day = floor(365.0*(1970 + $stamp/(60*60*365*24) - $year))
$hour = floor( ((365.0*(1970 + $stamp/(60*60*365*24) - $year)) - $day)*24.0)

I guess you can go from there to figure out the minutes & seconds.
 
Old 09-16-2008, 01:05 PM   #3
jchambers
Member
 
Registered: Aug 2007
Location: California
Distribution: Debian
Posts: 127

Rep: Reputation: 15
I do the following but you can use date in php as well.

`date_added` timestamp NOT NULL default CURRENT_TIMESTAMP

Code:
	<?
	list($date) = explode(' ', $row['date_added']);
	echo $date;  // 2008-09-15
	?>
Take a look at this link as well.
http://us3.php.net/date

Jon
 
Old 09-16-2008, 04:07 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
The PHP function date will accept two arguments, the first is a format string, the second is a timestamp.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Zone file(s) problem, datestamps keep updating on secondary DNS server. ipa Linux - Newbie 1 08-05-2008 10:58 AM
php-mysql dependancy problem after nitemare mysql upgrade. RHEL4 andrewc Red Hat 1 01-03-2006 04:16 PM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
php4 mysql, installation, php-pages with mysql info stay empty dnla Linux - Software 2 03-14-2004 02:54 PM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration