- mercromina responded to »error when i try to upgrade to the last version of dizkus module (3.1)« 08:01 PM
- craigh responded to »TagIt 3.0 for Zikula« 03:58 PM
- localrags responded to »Remove contents of nuke_sc_anticracker from Database« 11:30 AM
- jmvaughn responded to »Shoutit for zikula 1.3?« 09:31 AM
- mdee responded to »Different page content under one template (tpl file) based on URL« 07:17 AM
- espaan responded to »Categories disappear when editing ...« 08. Feb
- eledril responded to »How decrease zikula cpu usage« 08. Feb
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Wiki » ManipulatingDates
Additions
As an example we can use a course module that lets you add and edit courses with starting and ending dates (!startDate and !endDate database fields).
Please read ManipulatingTables first. Your ADODB data dictionary lines for the !startDate and !endDate fields should be:
The simplest way to fetch a database record is to use the DBUtil::selectObjectByID function:
That is all! The $course variable will now contain your date values formatted as a 'YYYY-DD-MM HH:MM:SS' string which can be reformatted later on using various utility functions.
Remember: dates are always manipulated as strings in the format 'YYYY-DD-MM HH:MM:SS'.
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling DBUtil::selectObjectByID. These are displayed as a blank values when using the dateformat plugin.
Deletions
As an example we can use a course module that lets you add and edit courses with starting and ending dates (startDate and endDate database fields). Please read ManipulatingTables first. Your ADODB data dictionary lines for the startDate and endDate fields should be:
The simplest way to fetch a database record is to use the DBUtil::selectObjectByID∞ function:
That is all! The $course variable will now contain your date values formatted as a 'YYYY-DD-MM HH:MM:SS∞' string which can be reformatted later on using various utility functions.
Remember: dates are always manipulated as strings in the format 'YYYY-DD-MM HH:MM:SS∞'.
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling DBUtil::selectObjectByID∞. These are displayed as a blank values when using the dateformat plugin.
Additions
To use it you must remember to put <!--[pncalendarinit]--> somewhere one the page before it. This will ensure that the proper javascript and stylesheets are loaded for the nice little calendar date picker you will get. This plugin does not add more than a calendar popup feature - you will have to add an <input> element for your self.
So far this is all you get. At the time of writing there is (to my knowledge) no dedicated features for reading dates back into the database. You will have to do date validation your self. You will also have to ensure the dates are in MySQL format before submitting them.
Deletions
To use it you must remember to put <!--[pncalendarinit]--> somewhere one the page before it. This will ensure that the proper javascript and stylesheets are loader for the nice little calendar date picker you will get.
There are still some undecided problems - The most import problem left is which format the user should enter the date in.
Additions
Manipulating Date Values
There are still some undecided problems - The most import problem left is which format the user should enter the date in.CategoryDeveloperDocs
Deletions
There are still some undecided problems - The most import problem left is which format the user should enter the date in.
Additions
To use it you must remember to put <!--[pncalendarinit]--> somewhere one the page before it. This will ensure that the proper javascript and stylesheets are loader for the nice little calendar date picker you will get.
There are still some undecided problems - The most import problem left is which format the user should enter the date in.
Deletions
To use it you must remember to put <!--[pncalendarinit]--> somewhere one the page before it. This will ensure that the proper javascript and stylesheets are loader for the nice little calendar date picker you will get.
Additions
As an example we can use a course module that lets you add and edit courses with starting and ending dates (startDate and endDate database fields).
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling DBUtil::selectObjectByID∞. These are displayed as a blank values when using the dateformat plugin.
Deletions
As an example we can use a course module that lets you add and edit courses with starting and ending dates (~startDate and ~endDate database fields).
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling ~DBUtil::selectObjectByID∞. These are displayed as a blank values when using the dateformat plugin.
Additions
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling ~DBUtil::selectObjectByID∞. These are displayed as a blank values when using the dateformat plugin.
Deletions
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling DBUtil::selectObjectByID∞. These are displayed as a blank value when using the dateformat plugin.
Additions
Empty Date Values
Deletions
Empty Date Values
Additions
The format used is that of PHP's date() function.
Empty Date Values
If you have allowed SQL NULL values in your date columns you will get PHP null values back when calling
DBUtil::selectObjectByID∞. These are displayed as a blank value when using the dateformat plugin.
Entering Date Value
There's a special pncalendarinput plugin to be used for entering date values:
<!--[pncalendarinit]-->
Please enter start date: <!--[pncalendarinput ...]-->
To use it you must remember to put <!--[pncalendarinit]--> somewhere one the page before it. This will ensure that the proper javascript and stylesheets are loader for the nice little calendar date picker you will get.
Please enter start date: <!--[pncalendarinput ...]-->
Deletions
(Work in progress june 5th 2006)
The format used is that of PHP's date() function.
Additions
Dates should be displayed like any other value in your pnRender template. The PHP code to do this would be:
$render = new pnRender('course');
$render->assign('course', $course);
return $render->fetch('course_user_view.html');
The template should be something like this:$render->assign('course', $course);
return $render->fetch('course_user_view.html');
Course period: <!--[dateformat datetime=$course.startDate]--> - <!--[dateformat datetime=$course.endDate]--> The dateformat plugin will reformat your date value according to it's default date format specifier (unspecified so far). If you want a different format you can supply that yourself:
Course period: <!--[dateformat datetime=$course.startDate format="m-d-Y"]--> - <!--[dateformat datetime=$course.endDate]-->
The format used is that of PHP's date() function.
Deletions
Additions
As an example we can use a course module that lets you add and edit courses with starting and ending dates (~startDate and ~endDate database fields).
Fetching Dates from the database
The simplest way to fetch a database record is to use the DBUtil::selectObjectByID∞ function: That is all! The $course variable will now contain your date values formatted as a 'YYYY-DD-MM HH:MM:SS∞' string which can be reformatted later on using various utility functions.Remember: dates are always manipulated as strings in the format 'YYYY-DD-MM HH:MM:SS∞'.
Displaying Dates
Deletions
As an example we can use a course module that lets you add and edit courses with starting and ending dates (startDate and endDate database fields).
(Work in progress june 5th 2006)
Dates can be slightly difficult to handle correct all the way from the database to the UI and back again, so here's a short introduction to how it should be done.
As an example we can use a course module that lets you add and edit courses with starting and ending dates (startDate and endDate database fields).
Creating Date Fields in the Database
Please read ManipulatingTables first. Your ADODB data dictionary lines for the startDate and endDate fields should be:
<?php
$sql = "...
startDate T,
endDate T,
...";
if (!DBUtil::createTable('courses', $sql)) { ... }
?>
$sql = "...
startDate T,
endDate T,
...";
if (!DBUtil::createTable('courses', $sql)) { ... }
?>
