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




Displaying The Date In A Different Format!


I have a row called Date in the databse which is saved as 0000-00-00 When I try to echo it, it shows like that 2007-04-16 Maybe because I use this normal code: echo $row['Date']; How can I display it like that:16-04-2007




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying Local Date In Specific Format
i'm trying to decide whether to use PHP or JavaScript to display a date on a website. what i'm wondering is where does PHP take the date from, the server or the client (ie will timezone become a factor). aswell as this, is there a simple way to allow the date to be displayed as: "22nd" "1st" or "14th" instead of "22" "1" or "14"?

Converting A Date Format (dd/mm/yyyy) Into A Time() Format
I want to convert a date in the format (dd/mm/yyyy) into a time() style format so I can compare it against the current time and only use information where its date is ahead of the current time.

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

Displaying Value As Epoch Format
I've been fiddling around and and come up with a solution for the current date
but when i try and display the results for the previous 5 days i am running into a slight
problem. This is what i have so far: PHP Code:

Displaying .txt Files And Maintainint Their Format Using Php
I wish to display .txt files within a php page. I have found out how to do this but any formatting such as paragraphs and tabs is lost. Can anyone help me with how to display the txt file as it is, formatting included? It is simply so we can update our Community Centre website with ease via txt files.

Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format.  For example the following text in this format including the lines in stored in the database:

Quote“Hello,

Welcome to the news for 11/06/07.

Thanks”
When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this.  Quote“Hello, Welcome to the news for 11/06/07. Thanks”  How do I get it to display in the format it in displayed in the database?

Format Source Code For Displaying On A Web Page
Is there a good function or plugin out there to format my source code examples?  I'm writing an article for a web page and want a very simple source code formatter.  Eg: code in black, comments in red, quoted items blue, key words green, class names bolded.

Date Format ...
I have dates with this format

1 9 99 00:00:00

I want to transform it in yyyy-mm-dd

how can I do with php ?

Help On Date Format
I have this page where user select month day and year from a drop down list and when the user pass it to selectdate2.php
it will be as treated one variable in a date format yyyy-mm-dd. any suggestion?

this is the first page named selectdate.php

<select size="1" name="month">
<option>01</option>
<option>12</option>
</select>
<select size="1" name="day">
<option>01</option>
<option>31</option>
</select>
<select size="1" name="year">
<option>2000</option>
<option>2003</option>
</select>

Date Format
I have a script running (with great effort and help from the group) that displays a date from a database and the amount of days to that date.

I would like to change the date into a more "human" format. The date now displays:

2002-12-08

I would like to change it to:

Sunday, December 08th

Is this a property of mktime()?

Date Format
Can a guru show me the equivalent of this code (that I use in Mysql), but need to replicate in MSSQL....

[MySQL CODE]
Date_format(Orderdate, '%y-%m') as period .... more statements
[/MySQL CODE]

How do I do this in MSSQL? The date is in this format in MSSQL DB.: 2003-11-30 00:00:00

**I have tried various things but my efforts are failing!

Date Format
I have a date in dd/mm/yyyy format i.e. 15/03/2007 The problem is that when I am storing this in MySql it uses yyyy/mm/dd format so the value stored in the DB ends up being 2015-03-20 Does anyone know how I can get around this problem?

Date Format
I can't figure out why the date did not came out correctly.

I wrote
Quote<?php
$b = "2006-03-01";
print date("m/d/y",$b);
?>

It suppose to come out as 01/Mar/06. But what what came out was 01/Jan/70. 
Can anyone tell me why this happens.

Date Format
if i have a date stored in my DB as 11/09/2007

is there anyway i can change it to 11th Sep once i have pulled it from the DB?

Time/Date Format
I'm pretty sure there is a way to do this, but I don't know what the code is to do what I'm trying to get.

Is there a way to get the current date and time in YYYYMMDDHHNNSS format (as an example, 20001030111100)? I would guess you can but I don't know what the code is.

Date Format Function Gone Bad
I am trying to clean up a DATETIME value from a Mysql database for presentation. So I am using the following basic function right out of devsheds recent article:

function cleanDate($val)
{
$arr = explode ("-", $val);
return date("M d, Y", mktime(0,0,0, $arg[1], $arg[2], $arg[0]));
}

Then feeding it a Mysql like DATETIME value for a test and echoing it to he page. Also I have added a current date echo to ensure that "it" knows that much.

$date = "2002-03-18 11:19:57";
echo "Updated " .cleanDate($date);
echo "<br>Todays date: " .date("F d, Y", mktime());

and here's my output....

Updated Dec 31, 1969
Todays date: March 20, 2002

Where have I gone wrong?

Date Format From MySQL In PHP
I've recently been successful in converting the MySQL date format YYYY-MM-DD to DD-MM-YYYY, but does anyone know of a way to actually format it so that it displays the corresponding months?

eg. 25-10-2003 = 25 Oct 2003

Convert A Date Format
I am displaying records from a table including a stored date. When
display $row[Date], i get the obvious 2006-05-21. However this is not
what the guy wants. He wants 21-May-2006.

I have tried several conversion functions but without success. I could
do a long winded function, but i hoped there would be a simple
solution.

MySQL / PHP Date Format
I am using php to call info from a mysql database. My date comes in format yyyy-mm-dd but I want it in dd-mm-yyyy. I know I need to use something like:

SELECT DATE FORMAT (date, %d-%m-%y)

But I'm not sure how to include it in my query which is also calling other items from the database:

$result1 = mysql_query("SELECT * FROM practice AS p, project AS t, regions AS r, gpcats AS c WHERE p.id = t.id AND t.region = r.region AND p.gpid = c.gpid AND gptext LIKE '%$search%' AND $region=0 AND '$cat'=&#390;'GROUP BY p.gpid ORDER BY verified DESC"

SQL Statement With DATE Format
i want to compare dates. The dates are like "2007-06-25".
I tried this:
$SQLString = "SELECT * FROM myDB.myTABLE WHERE dat_start = $act_dat";
But it didn't work.
What can I do?

Changing Date Format
If I fetch a date from a mysql field and the date is: 2006-01-12 00:00:00

Is there a way I can reformat it in php to lose the hr.min.sec so that I am just left with the date 2006-01-12??

Change Date Format
I would like to know how to change the date format in 31-JUL-2007 to 07-31-2007?

Changing Date Format
i hve a date variable in mm-dd-yyyy format how can i change it to mysql default format i.e., yyyy-mm-dd format ...

From Varchar To Date Format
i am having one problem with mysql.Previously i have created one Date field as varchar format.Now i want change that field as date fromat and also the data should be there as date format whatever i have stored previously.

Searchable Date Format
Whats the best searchable date format for php mysql ? Im after only showing news on and after the publish date specified.

So i first need to know which date() i should be using..

Iv researched date() and got date("Y-m-d"); , but is this searchable?

Also would need to know how to show only articles that have todays date or previous dates ( not future dates etc ).

How To Manupulate MySQL Date Format In PHP?
MySQL date format is yyyy-dd-mm. how can i make full manupulation of the date with php? For example, how can i make the date to 29-september-2002 and others manupulation.

Date Validation YYYY-MM-DD Format
Hi, I am using forms which input dates into a mysql table, these work fine. However I would like to validate these into the correct format which is YYYY-MM-DD. So I am guessing I need an ereg function which looks for a string of 4 followed by a dash, then 2 then a dash and finally two more.
The code I have so far is:

$date_pattern = "([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})";
if (!preg_match($date_pattern,$EventStart))
{
echo ("<br>Wrong date format");
$FormValid="False";
}

MySql Query, Php Date Format.
This is actually 2 questions, but they go to gethere so I'm asking them as one. First, how do I write a MySql query that returns all the rows that have a date in the date collum that is newer than todays date? Then I need to take those rows, format the date in them and then print them in a table.

Always Local Time & Date Format?
Is there a script available that would re-format a time & date always
according to the users' setting?

Some setting that would be read by the language set in the browser or from
the IP?

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

Date Stored In DB In The Following Format: 2004-06-29 09:06:36+01
I am trying to convert a date in the following format with the date
function (i.e. date("d/m/y", strtotime($dbdate));):

2004-06-29 09:06:36+01

The database was created by another programmer as I normally store my
dates as datetime type in the format:

2005-07-08 10:52:44

What Is The Proper Date Format For A Txt Database?
I would like to know what format should be used when writing to a txt file. I am trying to search between a start date and a ending date and list any variables For example.

if (($sDate <= $jdate && $eDate >= $jdate))

then I have it list the variables it will work if searching between months and days but it does not work if I have different years. I will get all years printed out.

my date format is m/d/Y 6/13/2001

If I search for example start date = 6/01/2001 and the ending date = 6/09/2001

I will get the correct month and day dates but I also get anything from the year before and including year in the future.

Date Format When Inserting Data
I am getting a date entry through POST by a form byt the format enetered by the user is 'dd/mm/yy' .... how could i use MYSQL PHP syntax to insert the proper format as it is default in the table in my database. which function is it?

PHP Date Conversion To Readable Format
i have FPDF (php script that generates pdf files from variables). I can get the from date and to date to show, but they show like this: e.g.: 2006-12-20
now im trying to do this but its not working: Code:

Date & Time Format In Database.
I'm using MySQL database, the problem is I've setup that user input the Date format in dd/mm/yyyy (example: 14may2007) and Time (example: 12:00pm). How do I convert it to Date & Time format in database format before insert into database? Sorry, noob here.

Date Format In Join Statement?
$get_matches=mysql_query("SELECT matches.match_id, matches.game, matches.opponent, matches.map, DATE_FORMAT(`matches.date`, '%d/%c/%y') AS 'matches.date', matches.time, players.player_id, players.match_id FROM matches, players WHERE matches.match_id = players.match_id AND players.player_id='$player_id' AND matches.game='$game'") OR die(' ERROR GETTING TOTAL $game MATCHES ' . mysql_error());

Basically I'm trying to format a date column from the american style date format into the european one, but for some reason its not working. I've got it working in non join statements but I don't know how to do it in a join statement.

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.

Dates And European Date Format
ATM my database is using an American style date format with the year coming first, then the month then the day, is there a way to set it so it goes day, month, year?

Basically how it works is I got 3 drop down boxes with days, months and years in it. The user choose the desired date clicks a button and it updates the db. My problem is its has that American format and if I put it as text then I won't be able to do calculations or sorts on the date so I need it as a date.

Also do I need to actually change anything in my mysql data base in regards to the date field atm I got it set as a date is there any additional things I gotta change?

Output Format For A Timestamp Date Variable
I have a variable - $lastdate - that is the latest date any record in a
MySQL database was updated. Its MySQL format is TIMESTAMP.

If I say [echo $lastdate] I get the output I'd expect - 20060424221549
which is a YYYYMMDDHHMMSS format.

I'd like to be able to display that using a format of mm/dd/yy with no
leading spaces on the month and day. I don't know what the php command
is to do this. In other words, I'm trying to display a variable -
$lastdate - formatted a certain way. I know that the formatting string
n/j/y will get my output looking as I'd like, but I can't figure out how
to apply that to my variable.

Preg_match() Error, Match Only Valid Date In Mm/dd Format.
I am trying to create a function that will match only valid date in mm/
dd format. (Month in, 01, 02, ..., 09, 10, 11, 12 and Dates in 01,
02, ..., 11, 12, ..., 30, 31).

I am trying this code, but it fails to work.

The error is :-
PHP Warning: preg_match(): Compilation failed: unmatched parentheses
at offset 15 in /home/wizard/regexDateTime.php on line xx

The code is here.

Date_FORMAT Need To Convert Back To MySQL Date Format
Below is a couple of snippets of code that I have for modifying the date format from MySQL and it works great.  The problem I am running into is later in the code I need to call the $AuctionDate variable to query the data field in another table.  This won't work because the format has been modified using date_FORMAT.  How do I convert it back to the MySQL date format so I can properly query the database. Code:

Displaying Date
i'm working on K Yank's book and, at some point, i've an insert like this:

$sql = "INSERT INTO Jokes SET
...
JokeDate = CURDATE()";

When i dysplay this on my webpage, the date format is YYYY,MM,DD
and in my country (Portugal), the format is day, month, year
How can i achieve it?

Displaying Date...
As a final touch to my current project I am trying to display a "Last Updated: " field on the user profile pages of the website. The SQL database is updating the field last_updated automatically any time a record is altered, and this is working fine...

Structure details from phpMyAdmin (in table 'users'): last_updated timestamp  ON UPDATE CURRENT_TIMESTAMP No 0000-00-00 00:00:00

However when I try to output this date I get the result:

Profile Updated: January 1, 1970

The code I am using is as follows... Code:

Displaying A Date
My current code:

foreach ($page['events'] as $z) {

echo '<b>', $z['date'],  '</b></p>';

}

Which is pulling "date" from a DATE field in the database. Would like it to display as 3-22-2007 ... instead of 2007-3-22 - I know theres a quick answer out there but cant find it.

Displaying A Date Range
I would like to display a user specified date range e.g Monday to Monday next week or maybe Monday next month. When I have the basic function worked out I would like to get Data from a Mysql Database. here is what I have thought about. Code:

Displaying A Date With Strtotime
I have successfully used strtotime to format the date on a webpage that is
pulled form a MySQL database in the form yyyy-mm-dd.

However, in another part of the webpage, I have to insert another date that
may contain a NULL entry in the database. If I use strtotime to format this
then it enters the current date, whereas I want it left blank.

Displaying Date From A Database
All I need to do is change the date so it reads, for example, May 1999 when it's displayed on the page. Code:

Displaying Date/time
I'm trying to display a datetime type which I save with NOW()

ie:
    // create query
    $query = "INSERT INTO purchase (category, location, price, time) VALUES ('$category', '$location', '$price', NOW())";
time is a datetime type

I want to just display the "time" part of time,  not the date

this is the code I'm using:
echo "<li><a href=".$_SERVER['PHP_SELF']."?category=".$row[5].">".date("G.i:s", $row[5]."</li>";
and getting a "Parse error: syntax error, unexpected ';' ..."

Displaying Modified Date Of A URL File
I want to display a web page with links to various documents and display the date each document was last modified next to the link. I've found the filemtime command and that works quite nicely for "local" files. However, filemtime doesn't work if the file(s) are refered to by their URLs (which is how I need to do it).

A comment on the manual page (http://www.php.net/manual/function.filemtime.php3) refers to having to use "Socket Operations" but the link posted with that comment doesn't work (it just goes to a page saying the website has been rearranged).


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