473,626 Members | 3,952 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_fetc h_row($result))
{
$tt= odbc_result($re sult,2);
echo date("d.m.Y", $tt).", ".odbc_result($ result,6) . " <br>";

S

Dec 5 '06 #1
4 2131
"Sonnich" <so************ @elektrobit.com wrote in message
news:11******** **************@ f1g2000cwa.goog legroups.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_fetc h_row($result))
{
$tt= odbc_result($re sult,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***@bhg byrzcv.arg)
Dec 5 '06 #2

Kimmo Laine wrote:
"Sonnich" <so************ @elektrobit.com wrote in message
news:11******** **************@ f1g2000cwa.goog legroups.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_fetc h_row($result))
{
$tt= odbc_result($re sult,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.com wrote in message
news:11******** *************@1 6g2000cwy.googl egroups.com...
>
Kimmo Laine wrote:
>"Sonnich" <so************ @elektrobit.com wrote in message
news:11******* *************** @f1g2000cwa.goo glegroups.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_fetc h_row($result))
{
$tt= odbc_result($re sult,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***@bhg byrzcv.arg)
Dec 5 '06 #4

Kimmo Laine wrote:
"Sonnich" <so************ @elektrobit.com wrote in message
news:11******** *************@1 6g2000cwy.googl egroups.com...

Kimmo Laine wrote:
"Sonnich" <so************ @elektrobit.com wrote in message
news:11******** **************@ f1g2000cwa.goog legroups.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_fetc h_row($result))
{
$tt= odbc_result($re sult,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
32415
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 query to format the date returned as a timestamp without having to do the conversion in php. Can someone tell me what to put in my db query?
5
2300
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 another time zone. It would be of great value if the time of some central source could be drawn, in the form of a ".js" file, into the script to avoid dependence on the client's date/time.
8
2664
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 to select today. example: var dtToday = Date() if(document.frmSoftware.txtDDate.value == dtToday) {
5
5527
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 handle these but fact is I'm not coding on a mac. Standard C functions that I've been looking at ( for example char *ctime(const time_t *time); ) take a time_t based on 01/01/1970.
2
2157
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. ============================================================= while (($data = fgetcsv($handle,5000, ",")) !== FALSE) { $mydate = $data; // here is the array value that holds the date }
6
4272
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 day... without specifying what the event is... just a simple checkbox..
11
10566
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)) || '-' || RTRIM(CHAR(YEAR(COVG_TYP_STRT_DT))) FROM twd_coverage_type 1 ---------------------------------------------------------------------------------------------------------------------------- 6-May-2006 1 record(s) selected.
3
3434
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 current date and time expressed in minutes? Once I have this number I can add the number of minutes purchased to the current date/time to get the expiration date.
9
2921
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 how I can/should do that? Or possibly point me to an on-line explanation? Thanks ps: if it makes any difference, the data is coming from a MS Access
0
8266
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8199
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.