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.





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 Complete Forum Thread with Replies

Related Forum Messages:
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 Replies !
Converting Numbers To Written Amount Strings
I'm wondering if there are any existing tools to convert a number to a written amount, like you would see on a check. Here are some examples of what I would like to do.

Convert 11 to 'eleven'
Convert 348 to 'three hundred forty eight'
Convert 1.25 to 'one and twenty five hundredths'

The last one isn't as important. I don't necessarily need to support decimals.

Is anyone aware of any PHP function, library, or anything else I can use to accomplish this easily. I'm sure I could come up with a custom solution, but it would be bulky and no reason to reinvent the wheel if I don't have to, right?

View Replies !
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 !
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 !
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 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 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 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 !
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 !
Timestamp Insert Issue: Windows / Linux
The DBMS can optimise for COUNT(*) in ways that it can't for COUNT(<field>) - it doesn't need to look at any fields, for example (and so uses fewer resources). If my table has a field named id that is primary and auto incrementing in MySQL, it is still better to use COUNT(*) instead of COUNT(id)? Do you also believe this is true when using SELECT (SELECT * instead of SELECT id, name)?

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 !
Regex Issue ... Context Selection Based On Word
I'm building a site search feature for our website, and I'm having a hard time. The results come from a MySQL fulltext search, which works fine. But I want PHP to select an excerpt from the body of the article so that the user knows in what context the search was made. Code:

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 !
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 !
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 !
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 !
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 !
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 !
Making A Timestamp From A Date
I have a date in the form: 2003-01-03 15:16:08

I need to make a time stamp from it - any ideas?

View Replies !
Fetch The Date From Timestamp
i have a mysql table with 3 fields

1.id  2.time 3.approved

values

1  1181237691  0
2  1181237703  0
3  1181237711  0

i want to fetch the distinct dates from this timestamp values using select statement.

i want to display like this
1  2007-06-07

second thing i want to update the approved value=1 where these distinct dates are equal to the above timestamps.

View Replies !
Date/time To Timestamp
Is there any built-in PHP function that can turn something like "2007-04-18 18:00:00" into a timestamp?

View Replies !
Convert A Date To A Timestamp.
I need to convert a date to a timestamp. e.g. 23/01/2006 into a unix timestamp. Is there a function that can do this?

View Replies !
Problem With Date() And Timestamp
I've used date() a million time before with a Unix timestamp pulled out of a MySQL database but this time it just isn't working as expected:

<?php
mysql_connect('localhost', 'x', 'x');
mysql_select_db('x');
$query = mysql_query('SELECT * FROM `pub_news` ORDER BY `date` DESC');
while ($row = mysql_fetch_array($query))
{
echo date("nS F Y", $row[date])."<br>";
}
?>

The two database values for the 'date' field are &#65533;' (5th May 2007) and &#65533;' (11th May 2007). The code outputs the correct values for the fields as $row[date], but date() displays both as 5th May 2007.

I have checked the server time and although it's a few minutes fast, it seems OK. Am I being really stupid and missing something obvious?

View Replies !
Date Converting
I am retrieving a date from mysql (using the mysql date format YYYY-MM-DD format). Is there an easy way to convert a date in that format:
YYYY-MM-DD
to this format:
MM-DD-YYYY

View Replies !
Converting To Date
I collect some data from a user registration form in the format:

Day: 1-31 Month: 1-12 Year- 1990-2007

how i can convert this into proper date format so i can store it in my database :P?

View Replies !
Getting A Readable Date From Linux Timestamp
I have a form that exists from 3 separate dropdown-lists.

The first list enables you to choose the year (YYYY)
The second list enables you to choose the month (MM)
And the third list allows you to choose the day (DD)

To make a timestamp wich is easy to compare, I create
a var. $date = "$year$month$day";

This var. combines the 3 values into 1 number (20030516)
PHP puts this number into a mysql db as an integer(8).

Now, while retrieving from the database, I would like to order by date, so 20030101 comes BEFORE 20030102.
This is easy but I have a little problem:

The date must be displayed in yyyy-mm-dd format after comparing it to today's date. So while retrieving, it is ordered by date and compared to today's YYYMMDD-timestamp.

So: How can I make YYYYMMDD look like YYYY-MM-DD ?
I prefer to do this with php.

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 !
Use The Timestamp To Display The Date And Time
i use the timestamp to display the date and time on my blog, but every time i edit one of my posts, it updates the timestamp. is there any way to stop this from happening?

View Replies !
Insert A Date Into A Timestamp In MySQL
I want to insert a date into a timestamp in MySQL as follows:

$date = date('U');
$uid=$row['userid'];
$updt = dbquery("UPDATE users SET last_login = '$date' WHERE userid = '$uid'");

This will not work for some reason.

If I :
$uid=$row['userid'];
$updt = dbquery("UPDATE users SET last_login = NOW() WHERE userid = '$uid'");

I get a MySQL Datetime inserted.

View Replies !
MySQL > Timestamp > Date Format
i know that MySQL uses the unix timestamp thing, and i can display the date by doing this
PHP Code:

View Replies !
Using The Date() Function To Display The Timestamp.
I am using a timestamp colum in my MySQL table, I generate a timestamp with
php using time(); When I pull the time from the table I get some date from
the 1970's... does anyone know whats going on? Im using the date() function
to display the timestamp.



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 !
Date Format / Timestamp Problem
I am facing one problem in php, mysql whenever i submit empty date to db, it automatically takes timestamp as 943900200 ('30-11-1999') which is creating problems in my application..... currently handling this problem by hard coding timestamp validation.

View Replies !
Display The Date From A Mysql Timestamp
i'm just trying to display the date from a mysql timestamp in php. using this line:

date('l dS of F Y h:i:s A', $PostDate);

but for some reason that line gives me this date:
Monday 18th of January 2038 09:14:07 PM

and the time stamp in mysql database is:

20050830100156

any idea what going on here?

View Replies !
Converting A Date To A Weekday
Would like to create a function that takes a date (for example: 20031009) as input and returns its weekday (thursday) as output.

View Replies !
Converting Date Formats?
I have some dates in a MySQL database that are in a 'Y-m-d' format.
Is there a way to have PHP read these dates and convert them to a
'd-M-Y' format?

View Replies !
Converting A Calender Date
I am converting a calender date..i got a example from PHP Manual. the code is PHP Code:

View Replies !
Converting Date To Minutes
I have $x="200504161035"
that is 10:35 on 16 April 2005.

My questuion: what is the *shortest* piece of code to convert that variable
to minutes? I have a feeling there is a PHP function that should be able to
do it but I cannot find it. The long way takes 5 lines of code.

View Replies !
Converting MySQL Date With PHP
is there a PHP function that will convert a MySQL formatted date like "2004-09-05" to "July 9, 2004"?

View Replies !
Converting A Variable To Date
I searched around for a bit and tried reading the documentation on the date function, but I think I'm missing something, and figured someone could probably answer this pretty quickly.

I'm coding a schedule creator for my school's television station. It's pretty basic (lots of forms and messy sql insertions). Code:

View Replies !

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