Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Converting A Date To Unix Timestamp


I have a form where people enter their birthday_day, birthday_month, and birthday_year

Is there a way to do the following;

convert_this_to_unix_timestamp($_POST['birthday_day'], $_POST['birthday_month'], $_POST['birthday_year']);

The point is that if i store it as a unix_timestamp, then i can do some math on it and return the users age instead of their birthday.




View Complete Forum Thread with Replies

Related Forum Messages:
Converting An SQL TIMESTAMP Into Unix Timestamp
I look over the docs on MySQL, and I'm assuming MS SQL will be quite similar. I am trying to decide how best to pull this off. I am anticipating a need to take the typical SQL TIMESTAMP and convert it to an Unix Timestamp...

Now, as I look at this a TIMESTAMP stores namely a "numerical" format in a 14 Digit String. I'm just wondering if anyone has a suggestion as to how I might split this into the componenets (4d Year/3d Month/2d Day/HH MM SS) so that it could be passed through mktime() (which will give me the unix version).

Actually, I think I may have an approach.. perhaps using the php substr() function..
since it returns a "defined" portion of a string.. if $x was our timestamp, we'd have to pass it through the substr() function a few times, to pull out the pieces we wanted.

View Replies !
Converting Stored Unix Timestamp
I'm using MySQL, and storing dates as unix timestamps in the database. Can I convert these to formatted dates within the SQL query, or can I only do it in PHP? MySQL seems to have a lot of functions to work with MySQL-format dates, but they only appear to convert TO unix dates, not FROM them. Is this true?

View Replies !
Converting UNIX Timestamp Into Datetime Format
When I use the getdate(); function to convert unix timestamp into datetime format all I getis the word array. What is the best way to convert unix timestamp into datetime format. Code:

View Replies !
UNIX Timestamp To Date
I looked in the forums little and in the php manual but I didn't find what I wanted. I want to know how I could change a unix timestamp into a normal date such as MMDDYYYY.

View Replies !
Date To Unix Timestamp
I am getting a date and time from a user. The send in a date with the format dd-mm-yyyy and a time with format hh:mm and then send in whether it is am or pm. now i split the date and time, then try to figure out the hour using: Code:

View Replies !
SQL Date/time Or Unix Timestamp?
Generally when developing applications I use unix timestamps as the method of storing dates in a sql database. However, I was wondering if I should use the standard date-time used by the database. The question then arises: continue using PHP to manipulate the dates, or allow the sql server to take over.

Can anyone provide any reasons to use sql date-time rather than unix timestamps?

View Replies !
Convert Unix Timestamp To Date('Y-m-d H:i:s')?
How do you convert a unix timestamp to date('Y-m-d H:i:s')?

View Replies !
Unix Timestamp Into Textual Date Time
How do i convert a Unix timestamp into English textual date time description? In my database i have stored the date and time as 1187079740 and now i want it to be converted into 14/08/2007 13:52:20. I have currently used

<?php
$format = '%d/%m/%Y %H:%M:%S'
$strf = strftime($format);
echo "$strf
";
print_r(strptime($strf, $format));
?>

I am generating data from a db to xml which gives date as <date>1187079740</date> Now my task is to convert SPECIFICALLY the value 1187079740 into it's actual textual form of 14/08/2007 13:52:20. I want the data 1187079740 to be written into a php script to generate it's textual time.

View Replies !
Convert User Entered Date And Time To Unix Timestamp Before Inserting To Database
How do you convert a user inputted date to a unix timestamp before
insterting it into your database? I have a form, with a textfield for
a date that the user inputs in the format mm-dd-yyyy and three dropdow
boxes for hours, minutes, and AM/PM. All of these need to be considered
together and converted to one Unix Timestamp and then inserted to the
MYSQL date field. The type of field is INT (11) so that I can instead
of the standard 0000-00-00 format of MYSQL so that I can do better
calculations and queries.

View Replies !
Regex Issue - Converting A Written Date To A Timestamp
I have a problem, somehow through one of my scripts, all the timestamps in my database were set to 0000-00-00 00:00:00. I can fix this because one of the fields contains the written date in this format "Wednesday, June 7, 2006", I think I need to make a regex expression that can read that and generate a new timestamp from it,

I'm just not sure where to start because I've barely used regex. Some of the dates are not in that format because it contains over two years worth of data, and I want to just delete the ones that are not in that format as well. I'd appreciate any help here, I'm kind of stumped. Once I match the expression I can generate the timestamp, but I don't know how to match it.

View Replies !
UNIX Timestamp
Array:

(
      [0] => 17:28
      [1] => 17:40
      [2] => 17:52
      [3] => 18:04
      [4] => 19:16
)

I know that 0 in the array is a value corresponding to the first Friday in this month, 1 to the second Friday etc. I want to change the key to the of the day its referring to.

View Replies !
Datetime Vs Unix Timestamp
I have been making a few minor "programs" using php. In them, I have a lot of date tracking and storing of various types of dates.

A while back I had used phpBB a lot and learned a lot about coding from modifying the forum to my needs. Well, they stored all dates as UNIX timestamps. Now I know that they have the ability to allow users to have their own date formats and be specific to different timezones.

Well, ever since then I have been using timestamps to record and compare any date or time info. I have been running into a lot of problems lately with it though. I cannot do dates before 1970 or after 2070. My dates have been coming out a few hours off also. Now I use various functions to change timezones for users and stuff, but even though I am very sure they are right, my times still come out wrong.

My big question is, does anyone know why they used the timestamp instead of datetime? I figure you can use datetime in the database and then convert/compare it any which way you want with php and sql statements. Are theere pros and cons? Specific reasons? I also know they support other databases than MySQL, is it because they may not have datetime?

View Replies !
Getting Time Of Day From Unix Timestamp
I'm working on my CMS, Thacmus, and I've run into one helluva snag (well, nothing big). I'm working on adding the time of day to my date field, since I've procrastinated on that, but I'm having trouble trying to get the time of day from the timestamp without it interfering with the day. I've managed to supress this with the two asterik'd Here's the code for the two fields, date, and time: Code:

View Replies !
Using Unix Timestamp As A Variable
im trying to create a traveling option that takes time to travel, and to make it work without crons.

Ive been going crazy for the past hour trying to get it to work somehow, and this is the current setup I have:

$r=mysql_fetch_array($q);
$unix=('unix_timestamp()');
$temp=($unix);
$city= ($r['citytime']);
$TTime=($temp + $city);

mysql_query("UPDATE users SET money=money-{$r['citycost']},destination={$_GET['to']},travTIME=$TTime WHERE userid=$ir['userid],$c);

Ive tested it alot, and if I just set $TTime equal to $unix, travTIME is set to the current unix timestamp. However, when I try to add $unix and $r['citytime'] together, travTIME is equal to $r['citytime'].

View Replies !
Unix Timestamp Update
I'm creating login using PHP/MySQL. I have Unix Timestamp (eg.1005882301). What will be the easiest way to update this filed to current date/time everytime when user log in? Should I rather use some other mysql date/time field type?

View Replies !
Unix Timestamp For 1st Jan 1970?
i changed my database from mysql timestamp to and int(11) so that i could use unix_timestamp, i then entered the correct dates for the posts, but all the code displays is the unix timestamp for 1st jan 1970 Code:

View Replies !
Convert Unix Timestamp
I'm trying to convert a Unix timestamp in a format to insert into a MS SQL datetime column (2007-05-03 16:38:04.620). Any ideas? I can insert the current datetime with getdate() but I have not been able to find out how to convert a Unix timestamp into the correct format.

View Replies !
13 Character Unix Timestamp
I am trying to generate a 13 character timestamp based on unix timestamp format and can't seem to understand where the 13 characters come from. I have seen results from multiple sites using this type of timestamp but can't seem to generate it myself. time() does give me most of it but it is only 10 characters. What are these last 3 that they are generating? Milliseconds or microseconds.

View Replies !
Adjest Unix Timestamp
I have a unix timestamp "1130006371" now as you can see I adjust it but when a print the new value in a time format it does not show anything else.. what is wrong??

$servertime = strtotime("now");
$nowtimecode = $servertime - 7200;
$printtime = date('G i', strtotime($nowtimecode));
echo $printtime;

View Replies !
Converting Unix Timestamps
I'm having some problems reading this on the PHP site. I need to do the following and don't know how to achieve it:

1. Convert a birthday into a unix timestamp (mm-dd-yyyy)
2. Convert it back.

View Replies !
Convert Datetime To Unix Timestamp
I have a datetime field: 2006-10-10 12:00:00 And I want to get that in seconds. Should I break the date and time and calculate it in two steps? or is there a quick way to do it in one step? I am trying to set the rate of a process execution between two datetimes and I am going to need everydate in seconds.

View Replies !
Using Unix Timestamp With Dates Before 1970
I made the following function to convert mysql dates YYYY-MM-DD into a string like Jan 3, 1995. The problem is that for dates before 1970, it fails, because I can't get time stamp.

How do I format dates without a timestamp? What do I do?

function format_mysql_date ($mysql_date) {

list($y, $m, $d) = explode ('-', $mysql_date);

return date("M j, Y", mktime(0, 0, 0, $m, $d, $y));

}

View Replies !
Making A Unix Timestamp Readable
i am using a login system with admin features and one of it is i can view a table with all active users and it tells me how long thier last movement was however it is displayed in a unixtimestamp Code:

View Replies !
Timestamp Comparison With Java.util.Date.getTime() Timestamp
I am forced to have to compare the value of some PHP timestamp with a
Java-based java.util.Date.getTime() timestamp. Let me show you how
they look:

View Replies !
Best MySQL Field Type For Unix Timestamp?
What do you recommend as the best type of field for a timestamp in a MySQL
database? I've considered varchar(10) or INT but I'm not sure what is the
best, most efficient, and most reliable field type.

View Replies !
Select Distinct Year From Unix Timestamp
I'm trying to select all distinct years from a unixtimestamp field in
MySQL database. I have a query:

SELECT DISTINCT YEAR(date_field) As theYear FROM table

but it gives me an empty array. What am I doing wrong?

View Replies !
Timestamp / Unix Time Stamp Querying...
Im baffled, officially!

Okay.

I have a table.

ORDERS
---------
ID
DateTime
Value

DateTime is generated by PHP and is a UNIX timestamp. I need to return all the orders, that were placed, say, between 4-5pm, on whatever day.

I see a few functions that should help me, FROM_TIMESTAMP, HOUR, INTERVAL...

but um... i just cant seem to crack how to do it... can someone just boot me in the right direction?

View Replies !
Converting Timestamp To EST
i'm trying to get my script to change the timestamp into EST because the time i am getting now is showing me 4 hours behind. here is the coding PHP Code:

$con_time=$serv1->fetchMatchingArray("PLAYEDAT");
if (preg_match ("/^[0-9]{10}$/", $con_time[0])) {
   for ($i=0; $i<count($con_time); $i++) {
    $con_time[$i] = $con_time[$i] + $adjust;
    $con_time[$i] = date('h:i:s a', $con_time[$i]);
       }
   $playtime = $con_time;
  }
else {
   $playtime = $con_time;
  }

if ($timeat == "0") {
      $playat = array_shift ($playtime);
   } else {
      $playtime = $playtime;
   }
am i missing something when i am trying to get it to display time. Right now a timestamp of 1128618980 is coming out as 12:16:20 pm and it should be 4:16:20 am.

View Replies !
Converting Timestamp
I have been trying to figure this out, and finally noticed what is causing the problem. I don't know how to fix it though. PHP Code:

// mysql query picks up the timezone.  mine is 1

$newdate = date('n/j/y g:i a', strtotime($sql->timezone . ' hours', strtotime($fulldate)));

If the strtotime($fulldate) = 8/2/07 0:01 am, the date comes out looking like this :

12/31/69 5:59 pm

how do I fix that?

View Replies !
Converting MySQL Timestamp
I was wondering if it was possible to convert a MySQL Timestamp to a regular date format.
I've tried time($row->date) and echoed the $row->date variable but it has no effect on the format.

I found this time($row->date) thing at php.net but it didn't do anything that I wanted. I'm trying to display a readable date from a MySQL Timestamp.

View Replies !
Converting Timestamp Into Minutes And Seconds
I am timing employees who take a test. I have the start time and end
time, which are unix epochs, and subtracing the start from the end
will give me a large number of seconds, for example 552.
I want to convert this into minutes and seconds.

View Replies !
Converting Timestamp To 3 Numeric Fields ?
I have written some code to collect the date from three input fields and store it as a timestamp date format. This is the code:

View Replies !
Converting A Year/week Number Into Timestamp
I would like to convert a year (2005) and week number (1-52) into a unix timestamp. Has anyone got any idea how to do this in MySQL?

View Replies !
UNIX Mktime To MySQL Date Or Date
A form that sends a starting date and an ending date. I have figured out how to tell the difference between the two and even rip the difference into an array because I need to compare the individual dates against a mySQL database to pull results from a particular date in a series. This is no problem. My problem is that teh mySQL database uses DATE as a field definition and this can not be changed. I managed to pull the date differences using some cleaver mktime stuff but no I do not know how to get this 1072242000 into this 2003-12-24...

Is there a function that reverses the mktime result into a usable date format? I would take anything at this point and I can explode and then array it to get what I want - but there has to be something. Code:

View Replies !
Unix Date Stamp Convert To UK Date
How do I go about converting the Unix date stamp to UK date/month/year. I know how to get the date from the database, I just need to know how I can convert this date using a php script to convert this to UK date format and display on my php page.

View Replies !
Converting Database Date To Normal Date
I am looking for a way to convert a date that is stored in a MySQL database like this after useing the date() function in PHP:

2006-08-16 21:03:54

and convert it into a date this:

16 August 2006 @ 11:03:54pm

Does anyone have some insight as to how I would go about doing that?

View Replies !
Textual Date To Unix Timestap
Is there an easy way to take a date and convert it to a time stamp. In the format of
September 12, 2001 - 05:00 pm I know I can explode it and so forth, but is their easier.

View Replies !
Order By Date When Date Not A Timestamp
I have a database of items with 2 fields, LogDate and LogTime.

I would like to be able to display these items ordered newest to oldest.

LogDate is a VarChar(11) and the format of the data is always DD-MMM-YYYY (30-AUG-2006)
LogTime is a VarChar(7) and the format is always HH:MMAP (02:47pm)

How can I order my SQL to sort by those 2 fields as if they were real dates?

View Replies !
Convert Date String To Unix Time
Basically I wrote a little script that captured the date as a string like "July 3, 2007". Well, now I'd like to take all the information recorded and put it into another database as unix time (I'm wanting to migrate my personally written scripts into a more robust pre-written forum script).

I think I need to use mktime(), but I'm not sure how to convert the string date above into something useable for mktime(). Any ideas?

View Replies !
Question About The "date / Time" Continuum - Timestamp Or Add Date As Varchar?
I have a new project that consists of work order tracking. It's nice cause I can use a lot of the same code from my last project which was delivery tracking. However when I tried to create a MySQL table using two timestamp fields, it stopped me. MySQL will only allow one timestamp.

So I did some googling and now am thinking I can use the php date function to get the date format of my choice and post the results into a textfield then post to MySQL as a varchar.

I'll still be able to sort date records the same in my queries and it's easier for me as a n00b to manipulate the data; Ditching the time and creating expressions / queries on timestamp fields gives me fits. Code:

View Replies !
Converting TIMESTAMP Fields Into "real Time"?
Is there a code for converting a db field that is TIMESTAMP into "real time"?
Meaning if the field is 2007-03-21 10:51:28have is output: "10:51 am",
Or: 2007-03-21 13:51:28output: "1:51pm"?

View Replies !
Timestamp -> A Useful Date
hi, i want to display a formatted version of the next 7 days on a page. I can add so many seconds to a timestamp, but, how do i convert that timestamp into a useful formatted date?

View Replies !
Get Timestamp Of Date
I have a date object which I want to get the timestamp for. The date is 24/8/2007 18:30:00 I simply want to determine what the timestamp is for this date and time so that I can compare it against the current timestamp. The problem is that the timestamp is for the current time, not the date and time that I have specified.
Here is my code:

  $mydate = date("d-m-Y : H:i:s", mktime(18, 30, 0, 8, 24, 2007));
  $datestamp = time($mydate);
  echo 'My date: '.$mydate.'  -  Date stamp: '.$datestamp;

View Replies !
Date From Timestamp(14)
I used echo date('l, F d, Y', $row['timestamp']); to get date from timestamp(14) in db. It says 'Tuesday, January 19, 2038' lieu 'Saturday, June 18, 2005' Why?

View Replies !
Timestamp To Date In Php
I really can't make sense into this to see why it's not working. I've looked at other examples on the net but I still get a weird date. I'm retreiving my date from a column called date llogin which is a datetime column which I'm storing using Date("Y-m-d H:i:s")
I have the following:

<?=date("d-m-Y", strftime($a1[llogin]));?>

But it's giving me this date.

31-12-1969.

View Replies !
A "bad" Unix Timestamp?
I ran into an interesting gotcha with unix timestamps.

I've got a page where the user inputs the date with drop-down boxes
(easy to deal with), that my script sees as (say) $d $m $y, not
necessarily in that order, but you get the idea, nicely formatted with
leading zeroes and so on.

Then I run it through checkdate($m, $d, $y) just to make sure the user
doesn't think there's 31 days in September or whatnot.

That's all fine. Then I think, well, it would be nice if I could tell
the user something like "there's not that may days in $m" and I should
be able to use strtotime() and date() -- but it turns out (and rightly
so) that you can't create a "bad" Unix timestamp.

For instance,

date ("F d Y",strtotime("2004-09-31"));

will return October 01 2004 and fwiw, so will

date ("F d Y",mktime(0,0,0,9,31,2004));

I can write a switch, of course, and there's only 5 cases (30 days
hath September etc., plus February needs to be dealt with). It
intrigues me, though, and I wondered if anyone else had played with it.

View Replies !
Getting Timestamp To Formatted Date
I have a timestamp field in a Mysql table and have tryed to get it to unix timestamp form and then format it with date() but i've had no luck. Can anyone enlighten me on how to do so?

View Replies !
Date From Form To Timestamp
If I have web form with fields: DAY, MONTH, YEAR, TIME, how can I get
Unix timestamp afther submiting that form.

View Replies !
Timestamp - Date And Time.
when i use this function for modificaton time of a file: $fdate = filemtime($file); i only get the date, but i want date and time.

View Replies !
Getting Date (timestamp) As Time Value?
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>";

View Replies !
Convert Date To Timestamp
Which one of the php functions will convert a date into a timestamp. I'm
looking at the date/time functions on php.net, but they all seem to work
the other way.

View Replies !
Mysql Date To Timestamp
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?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved