473,499 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting date (timestamp) as time value?

Hi

I'd like to read out a date from the a DB, but as time var. By default
I seem to get it as a string.

E.g.

while(odbc_fetch_row($result))
{
$tt= odbc_result($result,2);
echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>";

S

Dec 5 '06 #1
4 2124
"Sonnich" <so************@elektrobit.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
Hi

I'd like to read out a date from the a DB, but as time var. By default
I seem to get it as a string.

E.g.

while(odbc_fetch_row($result))
{
$tt= odbc_result($result,2);
echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>";

What kind of a string it is? If it's just a regular Y-m-d string, then the
easiest would be first converting it to unix timestamp and then passing that
to date:
date("d.m.Y", strtotime($tt));

strtotime parses the formatted date string and converts it to integer.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Dec 5 '06 #2

Kimmo Laine wrote:
"Sonnich" <so************@elektrobit.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
I'd like to read out a date from the a DB, but as time var. By default
I seem to get it as a string.

E.g.
while(odbc_fetch_row($result))
{
$tt= odbc_result($result,2);
echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>";


What kind of a string it is? If it's just a regular Y-m-d string, then the
easiest would be first converting it to unix timestamp and then passing that
to date:
date("d.m.Y", strtotime($tt));

strtotime parses the formatted date string and converts it to integer.
Server default format, I guess....
2006-12-05 00:00:00

Dec 5 '06 #3
"Sonnich" <so************@elektrobit.comwrote in message
news:11*********************@16g2000cwy.googlegrou ps.com...
>
Kimmo Laine wrote:
>"Sonnich" <so************@elektrobit.comwrote in message
news:11**********************@f1g2000cwa.googlegr oups.com...
I'd like to read out a date from the a DB, but as time var. By default
I seem to get it as a string.

E.g.
while(odbc_fetch_row($result))
{
$tt= odbc_result($result,2);
echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>";


What kind of a string it is? If it's just a regular Y-m-d string, then
the
easiest would be first converting it to unix timestamp and then passing
that
to date:
date("d.m.Y", strtotime($tt));

strtotime parses the formatted date string and converts it to integer.

Server default format, I guess....
2006-12-05 00:00:00
Then strtotime is your friend. Just pass the timestring the server gives to
strtotime and use the timestamp it returns.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Dec 5 '06 #4

Kimmo Laine wrote:
"Sonnich" <so************@elektrobit.comwrote in message
news:11*********************@16g2000cwy.googlegrou ps.com...

Kimmo Laine wrote:
"Sonnich" <so************@elektrobit.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
I'd like to read out a date from the a DB, but as time var. By default
I seem to get it as a string.

E.g.
while(odbc_fetch_row($result))
{
$tt= odbc_result($result,2);
echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>";
What kind of a string it is? If it's just a regular Y-m-d string, then
the
easiest would be first converting it to unix timestamp and then passing
that
to date:
date("d.m.Y", strtotime($tt));

strtotime parses the formatted date string and converts it to integer.
Server default format, I guess....
2006-12-05 00:00:00

Then strtotime is your friend. Just pass the timestring the server gives to
strtotime and use the timestamp it returns.
jup, but I'd also like to check whether <null... I found a way though.

Dec 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
32405
by: Ben | last post by:
I would like to use php to query a database and retrieve a unix timestamp. The problem is that mysql is storing the data in the date format and not a timestamp. I am sure that I can amend my...
5
2282
by: Gord | last post by:
Many scripts and calendars call client side system time in order to make presentations. However, the client's time may be improperly set, if set at all, and/or the relevant time may be from...
8
2660
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
5
5502
by: David Requena | last post by:
Hi All, I'm trying to parse a file which has some timestamps embedded. These're expressed as a number of seconds elapsed since 01/01/1904 (macintosh time). I know OS X provides some APIs to...
2
2146
by: johndcal | last post by:
Hello All, I have a date value that I pull from a .csv file. After reading the file and storing the values in an array the value of the date could be found in $array, for example....
6
4257
by: Kentor | last post by:
does anyone know of a script that would produce a calendar starting from todays date with checkboxes next to every day of the month so that the user is able to check it in case of an event for that...
11
10539
by: shsandeep | last post by:
I used the following query to retrieve the date in dd-mon-yyyy format. db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' || RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' ||...
3
3425
by: dave | last post by:
I need to compute an expiration date based on the number of hours, days, or months purchased. The expiration date needs to be expressed in minutes something like '1260481600'. How can I get the...
9
2902
by: Martin | last post by:
I'm retrieving some records from a database. One of the fields contains a date/time. I would like to format it as I send it out to the table in the displayed page. Can some one please tell me...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.